State Management · Senior · Question 16 of 75
Why is a module-level Zustand store dangerous in SSR (Next.js)?
- ✓Correct answer: On the server one module instance is shared by all requests, so users' data can leak
- 2Zustand can't run on the server at all
- 3The store is recreated on every import
Explanation
The Next.js guide recommends creating the store per request with createStore and passing it through a Context provider, then reading it with useStore(storeApi, selector). In a purely client SPA a global store is fine.