All topics
Stateintermediate

Zustand for Lightweight State Management

Learn how Zustand provides a minimal, hook-based global state store without providers or boilerplate.

Zustand is a small state management library that creates a store as a custom hook, without requiring a <Provider> wrapper around your app. You define a store with a create function that returns state and updater functions in a single object, and any component can subscribe to it by simply calling the resulting hook, optionally with a selector function to subscribe to just a slice of the state.

Zustand is like a shared notice board in a hallway anyone can walk up to and read or pin a note on directly, versus Redux's more formal office memo process (dispatch, reducer, approval) or Context's building-wide intercom that announces every update to everyone regardless of relevance.

Key Concepts

1
Compared to Redux, Zustand has drastically less ceremony: there are no action types, no reducers, no middleware setup required to get started, and updates are just plain functions that call set() with a partial state update (which is shallow-merged by default). This makes it attractive for small-to-medium apps or teams that want global state without Redux's structure.
set()
2
A key performance feature is selector-based subscriptions: a component that calls useStore((state) => state.count) only re-renders when count specifically changes, not when unrelated parts of the store change, because Zustand's hook compares the selected value, not the whole store object. This gives fine-grained reactivity without the context re-render-everything problem.
useStore((state) => state.count)count
3
Interviewers comparing state libraries often ask candidates to contrast Zustand's selector model with Context API's all-or-nothing re-render behavior, and with Redux's more structured but more verbose action/reducer pattern — a well-rounded answer positions Zustand as a middle ground in both complexity and boilerplate.