How a UI shares data across components without prop-drilling chaos. The most fashionable corner of frontend — every framework has its own family of stores.
← Back to Client Side| Library | Framework | Sweet spot |
|---|---|---|
| React Context | React | Built-in, low-frequency shared state (theme, auth). |
| Zustand | React (mostly) | Tiny, hook-based global store; minimal boilerplate. |
| Redux Toolkit (RTK) | React + others | Battle-tested for large apps; strict patterns + devtools. |
| Jotai / Recoil | React | Atomic state — fine-grained reactivity. |
| MobX | React, Vue, anywhere | Observable objects, automatic re-render. |
| Pinia | Vue | Official Vue store (replaced Vuex). |
| NgRx / NGXS / Signals | Angular | Redux pattern for Angular; Signals for fine-grained reactivity. |
| Svelte stores / Runes | Svelte | Built-in; Svelte 5 Runes are the modern default. |
| TanStack Query (React Query) | Any | Server-state caching — fetching, revalidation, mutations. |
| SWR | React | Vercel's lighter server-state library. |
| Apollo Client / urql | Any | GraphQL clients with built-in normalized cache. |
| XState | Any | State machines & statecharts for complex flows. |
The single biggest insight of the last 5 years: most "global state" was actually server data being mismanaged.
useStore(selector). Modern, ergonomic. Zustand is the prototype.Subscribe a component only to the slice of state it cares about — re-renders only when that slice changes.
// Zustand const userName = useStore(s => s.user.name); // re-renders only when name changes
Without selectors, every component re-renders on every state change — back to square one.
Redux Devtools (also works with Zustand & many others) lets you replay actions, inspect state diffs, and reproduce bugs deterministically. Essential for hard-to-reproduce UI bugs.
For complex flows (multi-step forms, video players, async sequences), explicit state machines beat ad-hoc booleans. XState models your UI as states + events + transitions; impossible states become impossible.
TanStack Query (React) or SWR — almost always.
useState + Context. Skip global state.
Zustand (React) / Pinia (Vue) / Svelte stores. Lightweight.
Redux Toolkit (React) / NgRx (Angular). Strict patterns scale.
XState — wizards, payment flows, players.
Yjs, Liveblocks, Replicache — CRDTs & sync engines.