{"schemaVersion":"1.0","record":{"label":"Zustand","description":"MIT-licensed state-management library with hook-based React stores, selectors and optional persistence middleware.","aliases":[],"kind":"software","website":"https://zustand.docs.pmnd.rs","overview":"Zustand is an open-source state-management library with a hook-based React API. A store contains values and update actions, and components subscribe to selected state. Optional middleware adds persistence. The compact interface can suit custom application state, but it does not remove the need to design immutable updates, server-rendering boundaries or stored-data migrations.","license":"MIT","lifecycle":"active","example":false,"features":[{"name":"Selected React store subscriptions","status":"supported","detail":"Components use a hook to select state; reading the entire store updates on every change.","useCase":"Shared client application state and selected persisted state","platforms":["React applications","JavaScript stores with appropriate integrations"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://github.com/pmndrs/zustand/blob/main/README.md","locator":"Hook stores, selectors and immutable updates","retrievedAt":"2026-10-07T23:17:14Z","kind":"vendor"}]},{"name":"Automatic deep merging","status":"unsupported","detail":"set merges one level only; nested structures need explicit immutable updates or helper logic.","useCase":"Shared client application state and selected persisted state","platforms":["React applications","JavaScript stores with appropriate integrations"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://github.com/pmndrs/zustand/blob/main/docs/learn/guides/immutable-state-and-merging.md","locator":"One-level merge and replacement flag","retrievedAt":"2026-10-07T23:18:05Z","kind":"vendor"}]},{"name":"Persistence and migration controls","status":"supported","detail":"Middleware can choose fields/storage, version stored data and migrate old representations.","useCase":"Shared client application state and selected persisted state","platforms":["React applications","JavaScript stores with appropriate integrations"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://github.com/pmndrs/zustand/blob/main/docs/reference/integrations/persisting-store-data.md","locator":"partialize, version/migrate, shallow merge and asynchronous hydration","retrievedAt":"2026-10-07T23:18:05Z","kind":"vendor"}]},{"name":"Hydrated values available immediately","status":"limited","detail":"Asynchronous storage hydrates later than the initial render; applications must account for that state.","useCase":"Shared client application state and selected persisted state","platforms":["React applications","JavaScript stores with appropriate integrations"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://github.com/pmndrs/zustand/blob/main/docs/reference/integrations/persisting-store-data.md","locator":"partialize, version/migrate, shallow merge and asynchronous hydration","retrievedAt":"2026-10-07T23:18:05Z","kind":"vendor"}]},{"name":"Shared global store for SSR requests","status":"unsupported","detail":"The Next.js guidance explicitly requires per-request isolation and no RSC store reads/writes.","useCase":"Shared client application state and selected persisted state","platforms":["React applications","JavaScript stores with appropriate integrations"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://github.com/pmndrs/zustand/blob/main/docs/learn/guides/nextjs.md","locator":"Per-request stores, matching hydration and RSC boundaries","retrievedAt":"2026-10-07T23:17:41Z","kind":"vendor"}]}],"alternatives":[],"slug":"zustand","draftAlternatives":[{"targetSlug":"redux-toolkit","status":"limited","detail":"Can replace Redux Toolkit for suitable shared React client-state workflows after rewriting actions, selectors and store organization. This does not reproduce Redux middleware contracts or optional RTK Query caching automatically.","useCase":"Shared client application state and selected persisted state","platforms":["React applications","JavaScript stores with appropriate integrations"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://github.com/pmndrs/zustand/blob/main/README.md","locator":"Hook stores, selectors and immutable updates","retrievedAt":"2026-10-07T23:17:14Z","kind":"vendor"},{"url":"https://github.com/pmndrs/zustand/blob/main/docs/learn/guides/immutable-state-and-merging.md","locator":"One-level merge and replacement flag","retrievedAt":"2026-10-07T23:18:05Z","kind":"vendor"},{"url":"https://redux.js.org/toolkit/introduction/getting-started","locator":"Slices, store setup and optional RTK Query","retrievedAt":"2026-10-07T23:17:02Z","kind":"vendor"}]},{"targetSlug":"jotai","status":"limited","detail":"Can replace Jotai for shared React client state when an object store with explicit actions and selectors suits the application. Reimplement atom dependencies and update logic, and preserve per-subtree store lifetimes where needed. This is a change of state model rather than compatible atom APIs.","useCase":"Shared React client state organized in object stores","platforms":["React applications"],"region":"Version and framework configuration apply","evidence":[{"url":"https://zustand.docs.pmnd.rs/learn/getting-started/comparison.html","locator":"Jotai state model and selector versus atom-dependency subscriptions","retrievedAt":"2026-10-09T03:49:00Z","kind":"vendor"},{"url":"https://jotai.org/docs/basics/comparison","locator":"Store organization, module/context scope and choosing between state models","retrievedAt":"2026-10-09T03:49:00Z","kind":"vendor"},{"url":"https://jotai.org/docs/core/provider","locator":"Independent subtree values and Provider remount behavior","retrievedAt":"2026-10-09T03:49:00Z","kind":"vendor"}]}],"evidence":[{"url":"https://github.com/pmndrs/zustand/blob/main/LICENSE","locator":"MIT terms","retrievedAt":"2026-10-07T23:17:41Z","kind":"vendor"},{"url":"https://github.com/pmndrs/zustand/blob/main/README.md","locator":"Hook stores, selectors and immutable updates","retrievedAt":"2026-10-07T23:17:14Z","kind":"vendor"},{"url":"https://github.com/pmndrs/zustand/blob/main/docs/learn/guides/immutable-state-and-merging.md","locator":"One-level merge and replacement flag","retrievedAt":"2026-10-07T23:18:05Z","kind":"vendor"},{"url":"https://github.com/pmndrs/zustand/blob/main/docs/reference/migrations/migrating-to-v5.md","locator":"React minimum, stable selector outputs and persistence changes","retrievedAt":"2026-10-07T23:18:05Z","kind":"vendor"},{"url":"https://github.com/pmndrs/zustand/blob/main/docs/reference/integrations/persisting-store-data.md","locator":"partialize, version/migrate, shallow merge and asynchronous hydration","retrievedAt":"2026-10-07T23:18:05Z","kind":"vendor"},{"url":"https://github.com/pmndrs/zustand/blob/main/docs/learn/guides/nextjs.md","locator":"Per-request stores, matching hydration and RSC boundaries","retrievedAt":"2026-10-07T23:17:41Z","kind":"vendor"},{"url":"https://redux.js.org/toolkit/introduction/getting-started","locator":"Slices, store setup and optional RTK Query","retrievedAt":"2026-10-07T23:17:02Z","kind":"vendor"},{"url":"https://zustand.docs.pmnd.rs/learn/getting-started/comparison.html","locator":"Jotai comparison: object-store state model and selector-based subscriptions.","retrievedAt":"2026-10-09T03:49:51.529Z","kind":"assessment"}],"document":{"version":1,"references":[{"url":"https://github.com/pmndrs/zustand/blob/main/LICENSE","locator":"MIT terms","retrievedAt":"2026-10-07T23:17:41Z","id":"license","title":"Zustand license","kind":"vendor"},{"url":"https://github.com/pmndrs/zustand/blob/main/README.md","locator":"Hook stores, selectors and immutable updates","retrievedAt":"2026-10-07T23:17:14Z","id":"readme","title":"Zustand overview","kind":"vendor"},{"url":"https://github.com/pmndrs/zustand/blob/main/docs/learn/guides/immutable-state-and-merging.md","locator":"One-level merge and replacement flag","retrievedAt":"2026-10-07T23:18:05Z","id":"merge","title":"Zustand immutable state and merging","kind":"vendor"},{"url":"https://github.com/pmndrs/zustand/blob/main/docs/reference/migrations/migrating-to-v5.md","locator":"React minimum, stable selector outputs and persistence changes","retrievedAt":"2026-10-07T23:18:05Z","id":"migration","title":"Zustand v5 migration","kind":"vendor"},{"url":"https://github.com/pmndrs/zustand/blob/main/docs/reference/integrations/persisting-store-data.md","locator":"partialize, version/migrate, shallow merge and asynchronous hydration","retrievedAt":"2026-10-07T23:18:05Z","id":"persist","title":"Zustand persistence","kind":"vendor"},{"url":"https://github.com/pmndrs/zustand/blob/main/docs/learn/guides/nextjs.md","locator":"Per-request stores, matching hydration and RSC boundaries","retrievedAt":"2026-10-07T23:17:41Z","id":"next","title":"Zustand Next.js guide","kind":"vendor"},{"url":"https://redux.js.org/toolkit/introduction/getting-started","locator":"Slices, store setup and optional RTK Query","retrievedAt":"2026-10-07T23:17:02Z","id":"redux","title":"Redux Toolkit overview","kind":"vendor"},{"url":"https://zustand.docs.pmnd.rs/learn/getting-started/comparison.html","locator":"Jotai state model and selector versus atom-dependency subscriptions","retrievedAt":"2026-10-09T03:49:00Z","id":"state-comparison","title":"Zustand comparison with Jotai","kind":"vendor"},{"url":"https://jotai.org/docs/basics/comparison","locator":"Store organization, module/context scope and choosing between state models","retrievedAt":"2026-10-09T03:49:00Z","id":"jotai-comparison","title":"Jotai comparison with Zustand","kind":"vendor"},{"url":"https://jotai.org/docs/core/provider","locator":"Independent subtree values and Provider remount behavior","retrievedAt":"2026-10-09T03:49:00Z","id":"jotai-provider","title":"Jotai Provider and store scope","kind":"vendor"}],"overviewCitations":["readme","persist"],"licenseCitations":["license"],"sections":[{"id":"store","heading":"Store and subscription workflow","paragraphs":[{"id":"store-detail","content":[{"text":"A Zustand store can contain state and the actions that update it. React components select the portions they need through a hook, without a provider in the simple client-only pattern. Selecting the entire store broadens the component's subscription. This makes the API concise, but the application still decides ownership, update boundaries and which state belongs outside individual components."}],"citations":["readme"]}]},{"id":"updates","heading":"Shallow merging is not deep mutation support","paragraphs":[{"id":"updates-detail","content":[{"text":"The set function merges at one level. Updating a nested object requires retaining its other fields explicitly, rather than assuming the store recursively merges them. A replacement flag disables merging entirely. For generated code, this distinction is important: a short nested update can discard neighboring fields even though the top-level update appears reasonable. The documented state model remains immutable."}],"citations":["merge"]}]},{"id":"version","heading":"Version 5 selector requirements","paragraphs":[{"id":"version-detail","content":[{"text":"The v5 migration guide raises the React minimum to 18 and changes equality handling. Selectors that return fresh references can cause update loops, with useShallow or stable fallback values offered as remedies. Custom equality functions use the separate traditional APIs rather than the basic create function. These are behavioral migration requirements, not just import renames."}],"citations":["migration"]}]},{"id":"persistence","heading":"Persist only the intended data","paragraphs":[{"id":"persistence-detail","content":[{"text":"Persistence middleware supports several storage backends, field selection through partialize and explicit version migrations. Its default merge is shallow, which can lose newer nested defaults when older partially persisted objects are restored. Asynchronous storage also hydrates after initial rendering, so a default value is not proof that there is no saved value. The application must distinguish loading persisted state from the settled state and decide what data should be retained."}],"citations":["persist"]}]},{"id":"ssr","heading":"Server rendering changes the simple-store pattern","paragraphs":[{"id":"ssr-detail","content":[{"text":"The Next.js guide warns that module-global stores can be shared across requests and requires a per-request store. It also calls for matching server/client initial data and says React Server Components should not read or write the store. The page notes that further guidance is being developed, so this article retains the explicit isolation boundaries without claiming a universal framework recipe."}],"citations":["next"]}]},{"id":"terms","heading":"License and substitution","paragraphs":[{"id":"terms-detail","content":[{"text":"Zustand is MIT-licensed. It can replace "},{"text":"Redux Toolkit","targetSlug":"redux-toolkit"},{"text":" for appropriate shared client-state tasks where its store and selector model fits. Redux reducers, middleware and optional server-data caching are separate migration concerns. No measured bundle advantage, performance ranking or hands-on migration is claimed."}],"citations":["license","readme","redux"]}]},{"id":"jotai-substitution","heading":"Choosing an object store instead of atoms","paragraphs":[{"id":"jotai-substitution-detail","content":[{"text":"Zustand can substitute for "},{"text":"Jotai","targetSlug":"jotai"},{"text":" for shared React client state when an application is easier to organize around an object containing values and update actions. Components can subscribe with selectors rather than composing primitive and derived atoms. This can suit a compact module-level store with explicit operations, while Jotai's atom model may be more natural for independently composed state. Moving an existing application requires translating atom reads, derived values and writes into store logic. Preserve any separate subtree lifetimes deliberately: replacing several scoped Jotai Providers with one global store would change which component instances share state."}],"citations":["state-comparison","jotai-comparison","jotai-provider"]}]}]},"id":"Q65","revision":1477,"updatedAt":"2026-10-19T08:31:36Z","sourceUrl":"https://substitutefor.net/entities/Q65?revision=1477"}}