zustand
๐ป Bear necessities for state management in React
Redux solves state management but brings enormous complexity: actions, reducers, selectors, middleware, and a steep learning curve for what is often a shared variable. Context API re-renders the entire subtree on every update. Zustand was built to provide global state with the simplicity of useState and the power of Redux.
A Zustand store is a custom hook. You define state and actions together in one object, and any component calls useStore(state => state.count) to subscribe to exactly the slice it needs. Only components that subscribed to changed state re-render. No providers, no reducers, no boilerplate.
Install zustand
npm install zustand
import { } from 'zustand';Use it when
Use Zustand for global UI state that multiple components need to read and write: auth status, theme preferences, shopping cart, modal state, or any data too complex for prop drilling but not complex enough to justify Redux.
Skip it when
Zustand is not designed for server state โ use React Query for that. For very large applications with complex state machines or time-travel debugging requirements, Redux Toolkit's tooling is more mature.
Ready to explore the full API?
See every class, function, and relationship in an interactive graph.