Next.js Discord

Discord Forum

Zustand on server side

Answered
rex1410 posted this in #help-forum
Open in Discord
Guys, when using zustand, I read this thread where people said that using zustand states on server side is a problematic approach with hidden bugs. But can I instantiate the zustand state on server side? Fetch from DB -> Set first Zustand State -> send to client side. Will this work without any issues?
Answered by rex1410
found an even better guide down in the docs, for the exact scenario https://docs.pmnd.rs/zustand/guides/nextjs
View full answer

8 Replies

@Ray thanks for the link, I missed this.
found an even better guide down in the docs, for the exact scenario https://docs.pmnd.rs/zustand/guides/nextjs
Answer
@Ray @joulev any idea about this one? its like a follow up doubt for this.. https://nextjs-forum.com/post/1225330229539504168
Prairie yellowjacket
hey did you manage to find a good solution?
yes
@Prairie yellowjacket hey did you manage to find a good solution?
the link I shared above is the thing
In short, you create a React Context, and provide state using that