How it works
You call create() with the starting values and the functions that change them, and get back a hook. Any component can call that hook and pick just the slice it needs, so it re-renders only when that slice changes. There is no provider to wrap the app in and very little boilerplate.
Middleware adds saving to localStorage (persist), Redux DevTools support and Immer-style updates. Zustand comes from the Poimandres collective (pmndrs), which also makes Jotai and React Three Fiber. It suits client state such as settings, carts and UI toggles; data fetched from a server is usually better handled by TanStack Query.
Zustand pros and cons
Pros
- Tiny, with almost no boilerplate
- No provider needed, and stores work outside React components too
- Components re-render only for the values they select
- Easy to persist to storage and inspect in Redux DevTools
Cons
- Few rules, so large apps need their own conventions
- Not built for caching server data (pair it with TanStack Query)
When to use Zustand
Pick it when
- Shared client state in small to large React apps
- Replacing heavy context setups or a Redux store that feels like overkill
Skip it when
- A large team that wants strict, enforced patterns (Redux Toolkit)
- The state is really server data
Zustand pricing
Zustand vs the alternatives
Related terms
More in Frontend
State and data