State management and data fetching · mid
Zustand, Jotai and Context: picking a client-state tool
Zustand is a tiny store with selector subscriptions (no provider needed), Jotai builds state bottom-up from atoms, Redux Toolkit is the opinionated choice for large teams, Context suits low-frequency values, and Recoil is archived.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Zustand:
create((set, get) => ({ count: 0, inc: () => set((s) => ({ count: s.count + 1 })) })), read withuseStore((s) => s.count). Selector subscriptions viauseSyncExternalStore; middleware forpersist,devtools,immer. - Jotai: atoms (
atom(0)) and derived atoms; components subscribe to exactly the atoms they read; good for fine-grained, graph-like derived state. - Redux Toolkit: conventions, devtools, middleware, RTK Query; good when many people work on shared state.
- Context: theme, locale, auth user, feature flags (low-frequency).
- SSR / Next.js App Router: never keep per-user state in a module-level store on the server (shared across requests). Create the store per request inside a provider.
- Recoil: the repository was archived on 1 Jan 2025 and is read-only; do not propose it for new work; migrate to Jotai or another tool.
- Choose by: update frequency, number of readers, need for devtools/middleware, team size, SSR needs.
The red pen
Common traps: mistake → fix
Mistake: "Recoil is a good modern choice"
Fix: archived in 2025.
Mistake: "Module-level Zustand store is fine in Next.js"
Fix: on the server it is shared between users.
Mistake: "Zustand needs a Provider"
Fix: not on the client; you add one for SSR per-request stores or testing.
Easy to hard
Questions interviewers ask, easy to hard
- Compare Zustand, Jotai and Redux Toolkit for client state.
- Selector subscriptions vs an atom graph: what is the difference?
- Why must stores be per-request in Next.js App Router?
- Where does Recoil stand today?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.