pinia-plugin-persistedstate: Persist state in nuxt3 not working
Describe the bug
Hey guys,
I would love to use this plugin to persist state, but for me it is not working right now. Maybe I do something wrong, but I have created a very simple reproduction link and when I look into my dev tools, there are no cookies written in to the cookie storage.
Thanks so much for your help.
Best regards Chris
Reproduction
https://stackblitz.com/edit/nuxt-3-z5lbsn?file=app.vue
System Info
System:
OS: macOS 12.5.1
CPU: (10) arm64 Apple M1 Max
Memory: 483.38 MB / 64.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.0 - /usr/local/bin/node
Yarn: 1.22.18 - ~/.yarn/bin/yarn
npm: 9.2.0 - /usr/local/bin/npm
Browsers:
Brave Browser: 108.1.46.138
Chrome: 108.0.5359.124
Safari: 15.6.1
Used Package Manager
yarn
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- The provided reproduction is a minimal reproducible of the bug.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (5 by maintainers)
Hi, For information, I’ve updated all my npm packages with the last release and now it works with “cookies” storage !!! Thanks!
And how to explain that :
doesn’t work on my Nuxt3 App with SSR ?
Ah, it seems the docs for Nuxt now suggest setting
storage
topersistedState.localStorage
- this does indeed seem to work.Aaaaah that’s it. Okay maybe it would be nice to add this in the docs or I overread it. Or this is clear to everyone except me 😉 thanks for the great work.
Hi, I tested and it works (with your example)?
The thing is you need to change the state for it to be persisted (or call
$persist
) as there is no point automatically persisting a state that is equal to the initial state.