Zustand
UI library · Free
A small state library with an external store and subscriptions: connects React components to shared data without extensive boilerplate.
Also known as: pmndrs/zustand; zustand; state-management-library; bear-state-management

What you can use for free
Code and local use under MIT.
Paid features and costs
Computing resources, self-hosting, and external services are paid for separately if used.
Access and limitations
Code and local use under MIT. Computing resources, self-hosting, and external services are paid for separately if used.
Use cases
- Share state between React components
- Subscribe components to the required store selectors
Example workflow
A possible workflow; this is not a report of hands-on testing.
Share state between React components.
Before you start
- The component's design, states, and data.
- A compatible framework and the project's styles.
Steps
- Describe store data and actions that change state.
- Subscribe components to the required store selectors.
- Configure styles and check empty, loading, and error states.
Check your result
- The keyboard, focus indicators, and a screen reader let users complete the action.
- The component works on a narrow screen and with long data values.
Choosing Zustand
Share state between React components
Choose this when
- Share state between React components
- Subscribe components to the required store selectors
Consider alternatives when
- When choosing for this topic, compare Zustand with Immer. A candidate to compare under the topic: Design systems, UI components. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together.
- When choosing for this topic, compare Zustand with Jotai. A candidate to compare under the topic: Design systems, UI components. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together.
Requirements
- Update state immutably and choose the required selectors. If a selector assembles several values into a new object/array, the README demonstrates useShallow for comparing the result.
Things to consider
- Costs and limits of free use: Computing resources, self-hosting, and external services are paid for separately if used.
- Terms of use: MIT for the code; dependencies have separate licenses.
- set with replace=true replaces the entire store, including actions. The README also advises against adding state through external store utilities in React Server Components because of possible errors and data leaks between users.
Frequently asked questions
What can you use for free in Zustand?
Code and local use under MIT.
What additional costs might arise with Zustand?
Computing resources, self-hosting, and external services are paid for separately if used.
What terms of use matter for Zustand?
MIT for the code; dependencies have separate licenses.
How do you get started with Zustand?
Describe store data and actions that change state. Subscribe components to the required store selectors. Configure styles and check empty, loading, and error states.
Why did the action functions disappear after clearing the store?
In the README, set({}, true) clears the entire store, including actions. Normal set merges new state by default, while its second argument enables full replacement; during reset, explicitly preserve or restore the required model.
Related tasks and approaches
- Immer
A candidate to compare under the topic: Design systems, UI components. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together.
- Jotai
A candidate to compare under the topic: Design systems, UI components. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together.
- Valtio
A candidate to compare under the topic: Design systems, UI components. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together.
License
MIT for the code; dependencies have separate licenses.
MIT — permissive license
You can use, modify, distribute, and sell the code, including in a closed-source commercial product. When sharing copies or substantial portions of the code, retain the license text and copyright notice. You do not need to open-source your entire project; the author provides no warranties.
License termsTechnologies and topics
- Zustand
- UI
- Development