Comments (5)
Hi, there are some examples of configuration in the docs:
import { defineStore } from 'pinia'
export const useStore = defineStore('main', {
state: () => {
return {
someState: 'hello pinia',
nested: {
data: 'nested pinia',
},
}
},
persist: {
key: 'store-key',
storage: window.sessionStorage,
paths: ['nested.data'],
beforeRestore: context => {
console.log('Before hydration...')
},
afterRestore: context => {
console.log('After hydration...')
},
},
})
I'm still in the process of writing proper docs for it. Does that answer your question ?
from pinia-plugin-persistedstate.
Thanks your reply.
I meet some trouble in Nuxt3. I test use example config with docs, but it can't resolve. So i hope to improve the example.
I can't see any cache in my cookies about this store, but other store was fine. (I test setup
& configure
pinia options, but they were unsuccessful )
from pinia-plugin-persistedstate.
Same problem here, not working with Nuxt3 anymore. It worked fine on Friday, after that it's not setting the cookie anymore. I've tried loading plugin as client also, no difference. Maybe something has changed in Nuxt about cookies?
from pinia-plugin-persistedstate.
Can you provide a proper reproduction repo? It still works fine on my side.
from pinia-plugin-persistedstate.
I'm defining the plugin as per documentation, this is my store. This code set the cookie few days ago but doesn't anymore.
import { defineStore } from 'pinia'
export const useCartStore = defineStore({
id: 'cart-store',
persist: {
paths: ['uuid'],
},
state: () => ({
uuid: null,
}),
actions: {
updateCart (payload) {
this.uuid = payload.uuid
}
}
})
I cannot give full repo right now, but will try to make it in following days.
Update: nevermind. I'm using ssr and using a cart store in a module so in some combination my store wasn't imported when loading persistent store in plugin. Works perfectly now 😃
from pinia-plugin-persistedstate.
Related Issues (20)
- Persistence doesn't work? HOT 3
- How to handle this warning? Inconsistent rendering between server and client HOT 3
- reactive([1]) Unable to deserialize properly HOT 2
- Save to store after X seconds of no further changes. HOT 1
- Having interval inside a persistent store breaks persisting
- [pinia-plugin-persistedstate] Error: [nuxt] A composable that requires access to the Nuxt instance was called outside of a plugin HOT 2
- In the cookie store defineNuxtRouteMiddleware method was used in nuxt3 unable to get to the store of value HOT 3
- Critical security vulnerability? HOT 6
- nuxt bug Cannot read properties of undefined (reading 'sessionStorage') HOT 1
- Automatically set `Vary: Cookie` response header in Nuxt SSR
- pinia.use(piniaPersist) in a separate file, causing local storage to fail HOT 2
- Missing "./package.json" export HOT 1
- Not effective when working with vee-validate
- Global `cookieOptions` are not applied in Nuxt 3 HOT 1
- Type safe persist paths HOT 2
- Store not hydrated from cookies when used with `@nuxtjs/i18n` and `routeRules`
- Using store outside setup(), state persistence is not possible HOT 1
- The type of map print in console.log (typeof this.userMap) is object HOT 1
- Persist for "composition api" style HOT 1
- 配置 storage: persistedState.sessionStorage 会导致 v-bind 失效
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pinia-plugin-persistedstate.