Skip to main content

Zustand

What is Zustand

Zustand is a lightweight state management library for React. The name means "state" in German. It is MIT licensed, currently at version 5.x, and has ~21.6M weekly npm downloads with 57k+ GitHub stars. Despite its small size (~1 kB gzipped), it covers the vast majority of client-side state management needs.

Why we recommend it

  • Minimal boilerplate — define a store in a few lines, no action types or reducers ceremony.
  • No providers — stores live outside the React tree, so there's no need to wrap your app in context providers.
  • First-class TypeScript support — stores are fully typed with minimal effort.
  • Rich middleware — built-in support for persistence, devtools, immer, and more.
  • Tiny bundle — adds negligible weight to your application.

Why over alternatives

  • vs Redux — Zustand achieves the same goals with significantly less boilerplate. No action creators, no reducers, no middleware pipeline to configure. If you don't need Redux's ecosystem (e.g., Redux Saga), Zustand is simpler.
  • vs React Context — Context triggers re-renders for all consumers when any part of the value changes. Zustand uses selectors, so components only re-render when the slice of state they read actually changes.
  • vs useState / useReducer — these are great for local component state, but once you need to share state across unrelated components, prop drilling gets painful. Zustand is for that shared/global layer.

When to use

  • Global or shared client state — authentication status, user preferences, UI state (sidebar open/closed), shopping cart, etc.
  • Projects outgrowing prop drilling or deeply nested context providers.

When NOT to use

  • Local component state — stick with useState or useReducer. Not everything needs a store.
  • Server state — data fetched from APIs (caching, refetching, pagination) is better handled by dedicated tools.
note

For server state (API data, caching, background refetching), use TanStack Query or SWR instead of Zustand. These tools are purpose-built for the async data lifecycle and handle cache invalidation, retries, and deduplication out of the box.

Resources