adding Cookie Storage to atomWithStorage #1833
-
In my recent project I needed to sync atoms with cookies and came up with the following recipe, I thought it might be beneficial to add it to the docs as people might need this.
Define Cookie Storage:
CreateStorage:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Yeah, it would be nice to have something like that in persistence guide. Also, we need to revisit the structure of persistence guide entirely. Maybe, you can help on it too (in a separate PR). |
Beta Was this translation helpful? Give feedback.
Yeah, it would be nice to have something like that in persistence guide.
Would you like to open a PR?
I think it would be better to have to recipes separately: a) zod with localStorage, and b) JSON.parse with cookieStorage.
Also, we need to revisit the structure of persistence guide entirely. Maybe, you can help on it too (in a separate PR).