pinia-plugin-persistedstate icon indicating copy to clipboard operation
pinia-plugin-persistedstate copied to clipboard

feat: split to multiple cookies & support for other storage options

Open stephenjason89 opened this issue 3 years ago • 1 comments

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 image

stephenjason89 avatar Aug 05 '22 12:08 stephenjason89

Please let me know if you want this integrated with createPersistedState instead of just createNuxtPersistedState

stephenjason89 avatar Aug 06 '22 12:08 stephenjason89

Not sure if it's possible or helpful, but I want to upvote this PR 😺

andrewdleach avatar Aug 18 '22 21:08 andrewdleach

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

prazdevs avatar Aug 24 '22 09:08 prazdevs

Closing this for now. I'll wait for the official release of Nuxt to start working on a serious and consistent solution 💤

prazdevs avatar Sep 08 '22 18:09 prazdevs

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

stephenjason89 avatar Sep 09 '22 01:09 stephenjason89