pinia-plugin-persistedstate
pinia-plugin-persistedstate copied to clipboard
feat: split to multiple cookies & support for other storage options
added support to split into multiple cookies & all storage driver that support get() & set()
- BREAKING CHANGE: removed support for useCookie
- RECOMMENDED ALTERNATIVE: cookie-universal or js-cookie
fixes: https://github.com/prazdevs/pinia-plugin-persistedstate/issues/84
a step closer to fixing: https://github.com/prazdevs/pinia-plugin-persistedstate/issues/77 see https://github.com/prazdevs/pinia-plugin-persistedstate/issues/97#issuecomment-1207200551 for more info
Description
Added an option to split the cookies to multiple cookies. Changed syntax similar to storage.get() storage.set()
Use https://github.com/microcipcip/cookie-universal/tree/master/packages/cookie-universal to persist cookie changes from SSR to client
or js-cookie for client only persistence in cookie
use it like so

Please let me know if you want this integrated with createPersistedState instead of just createNuxtPersistedState
Not sure if it's possible or helpful, but I want to upvote this PR 😺
Posting my thoughts in this PR so I dont forget it:
Considering offering compatibility with as many storages as possible through drivers, basically interfaces between any storage and the plugin's storage, instead of passing the cookies from js-cookie to the storage option, you'd pass the storage from pinia-plugin-persistedstate/drivers/js-cookie.
Now, I'll have to find a way to make it work with a consistent and easy to use API
Closing this for now. I'll wait for the official release of Nuxt to start working on a serious and consistent solution 💤
This PR mainly implements cookie splitting and nothing is needed in the official nuxt release. Furthermore, I'm aware that you want it to be 0 dependency package, but using it with only useCookie of nuxt defeats this purpose. So instead i reimplemented it to accept any storage driver that the user chooses which has a .get() .set() syntax.
I hope you reconsider