• English
  • Reference

    APIs

    Core functions for creating and configuring stores.

    • create — Create a store bound to React via hooks.
    • createStore — Create a standalone store without React.
    • createWithEqualityFn — Like create, but with a custom equality function.
    • shallow — Utility for shallow comparison of objects and arrays.

    Hooks

    React hooks for reading and subscribing to store state.

    • useStore — Access and subscribe to a vanilla store from a React component.
    • useStoreWithEqualityFn — Like useStore, but with a custom equality function.
    • useShallow — Derive a stable reference from a selector using shallow comparison.

    Middlewares

    Composable middleware functions for extending store behavior.

    • persist — Persist and rehydrate state using localStorage or a custom storage engine.
    • devtools — Connect a store to Redux DevTools for time-travel debugging.
    • redux — Use a reducer and dispatch pattern similar to Redux.
    • immer — Write state updates with mutable syntax using Immer.
    • combine — Combine separate state slices into a single store with inferred types.
    • subscribeWithSelector — Subscribe to a slice of state with selector and equality support.

    Integrations

    In-depth guides for using Zustand alongside third-party libraries.

    Migrations

    Upgrade guides between major versions.

    Previous versions

    APIs that existed in older versions of Zustand and are no longer recommended for new code.

    • createContext (v3) — The createContext export from zustand/context, deprecated in v4 and removed in v5.