Example of NextJS 13 with Zustand 4.3.3 (SSR, CSR) #1652
Replies: 2 comments 2 replies
-
@hiroyukinuri any idea on how to use the store using the Next.js 13 app directory ? How to set and get states in SSR components ? |
Beta Was this translation helpful? Give feedback.
-
Hey, here's a tough one @hiroyukinuri , I applied your solution to hydrate the Zustand store from getServerSideProps and it worked great, but my big problem now is the tests, for some reason when the snapshot is taken, it doesn't reflect correctly the information it should have (labels, links, placeholders, etc). |
Beta Was this translation helpful? Give feedback.
-
I created an example on how to use Zustand 4.3.3 with NextJS 13.1.1 while still using the context provider and slice features, I don't know if this example covers all rendering cases but it seems to be working well for SSR & CSR.
https://stackblitz.com/edit/nextjs-zy4agp?file=pages%2Findex.tsx
Would love to get feedback and know how this implementation could be further improved.
Beta Was this translation helpful? Give feedback.
All reactions