pinia-plugin-persistedstate
pinia-plugin-persistedstate copied to clipboard
feat✨: allow to change and persist cookie before nuxt init
Description
when opening a page on bowser, nuxt will be initialized and generate a html as response. if you are doing some thing like useStore and change store with nuxt's plugin, it will not persist state because there is no nuxt instance.
so, I make a new nitro plugin to make sure the initialize connection can obtain data of cookies from client side, and set cookies after pinia store is changed.
but the problem that our plugin is not able to get nuxt instance is still unresolved, so I provided a method to tell the plugin what to pass.
Linked Issues
#221
Additional context
maybe we need to test how it work after many revision
will have a look when i get some time 👍
sorry been really overloaded with work atm, havent found time yet to look into it 😓
I checked a bit and played with it. I like where this is going and it makes working with stores in middleware possible, however, I'm not sure this is the final API we want, especially the persistCookie . Maybe we can find a way to reuse the store config ?
I checked a bit and played with it. I like where this is going and it makes working with stores in middleware possible, however, I'm not sure this is the final API we want, especially the
persistCookie. Maybe we can find a way to reuse the store config ?
I try to do the same thing inset the plugin like persistCookie doing, but it's not possible to obtain event because the env of plugin is lay in outside of nuxt(I cannot understand).so I have to extract it for users to use. maybe someone can come up with a better plan? :P
Ok so maybe we could just copy/paste the pick method to the nuxt plugin to avoid touching the base plugin at all while we work on the Nuxt thing.
Later if we ever export it, we may want to strip it from types as it's an internal thing as well 🤔
Then we merge and move forward to see how we can improve it. But at least people can try playing around with it. Maybe tag is as experimental or sth
cannot agree more
maybe, we can use the get and set of lodash-es instead of pick and others? then each performs its own functions.
Ig it's fine using lodash-es in the Nuxt plugin, we'll see later what we can do. This issue has to be adressed so let's try things! I let you update the PR with whatever is needed from lodash to avoid changing the base plugin. So modifications only happen in the Nuxt package. :)
I'm sorry I have no enough time to do it last week. maybe there's time in a few days.
nw take your time ^_^ lodash are working on a v5 with native typescript, usm exports so could be a good start to see what we can do with it when they're done too. if it's really worth it we can always even put it in the main plugin. 👍