Can zustand persist() work within an SSR app? #1797
Unanswered
piscopancer
asked this question in
Q&A
Replies: 1 comment 2 replies
-
it flickers in zustand too...it still take sometime to read the data from the localstorage |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Persist refers to local storage as a browser API so it is unreachable during SSR. The page is loaded during SSR with default values or fetched values (we all know what) and only then does Zustand does its work checking for data in local storage and updating the state thanks to persist() function. I have not used Zustand with NextJS. I wonder if values are going to flick and shake🤔
Why am I asking? I am currently working with Qwik framework and Zustand is incompatible. Qwik uses SSR and I am using loading data from local storage to the state. However SSR loads in the 'default' values of store and only after SSR qwik requires ~0.1s to run all javascript and only then local storage can be checked for values. So the flicker or flashing of values takes ~0.1s and that's annoying. There is not flicker in zustand.
Beta Was this translation helpful? Give feedback.
All reactions