Skip to content
D
Documentation

Introduction

overview
2 min readUpdated

Zustand is a state-management library for developers building React applications or using stores outside React. A store holds state independently of React; a bound hook lets your components select the values they need without a context provider. Start with state and actions, then add persistence, debugging, or other middleware when your application needs them.

Package and entry points

zustand provides the stores, React bindings, and middleware described below. Install it in your project:

bash
npm install zustand

These are entry points of the same package, not separate packages to install. Follow each reference link for its exports, types, and signatures.

Entry pointWhat it provides
zustandThe core store API and React bindings together.
zustand/vanillaStandalone stores with imperative reads, updates, and subscriptions, without importing React.
zustand/reactReact hooks for creating bound stores and subscribing to vanilla stores.
zustand/middlewareMiddleware for persistence, Redux DevTools, reducer-based actions, inferred state, and selector subscriptions.
zustand/react/shallowA React selector helper that retains a previous result when the new result is shallowly equal.
zustand/vanilla/shallowShallow comparison without importing React.
zustand/shallowBoth the shallow comparator and the React selector helper.
zustand/traditionalReact bindings that accept custom equality functions; these use the additional use-sync-external-store package.
zustand/middleware/immerDraft-based state updates using the additional immer package.

The guides for custom equality and Immer include the additional installation commands for those integrations.

Start with React

Take the React quick start to install Zustand and build a typed counter with an action and component selectors. If you need a store outside React, read Stores and React bindings to distinguish the standalone store from its React hook.

Find your task

Concepts

How Zustand works connects independent stores, immutable updates, selector subscriptions, and actions; continue with Stores and React bindings, Immutable state and merging, and Selectors and rendering for the details that shape your code.

Guides

API reference

Use the entry-point references above when you need an exact signature, type, or option rather than a task walkthrough: start with the core package for stores and React hooks, or middleware for composable store behavior.

Was this page helpful?