npm / zustand
zustand
What changed in zustand 4 to 5, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
29 breaking6 new APIs and options1 performance4 behavior and defaults2 tooling14 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initzustand 533 changes
Breaking changes 9
The create function no longer supports customizing its equality function; use createWithEqualityFn or useShallow for the described cases.
Default exports are dropped; update imports to use named exports.
ES5 support is dropped.
The persist middleware no longer stores the initial state during store creation; set state explicitly after creation if needed.
React 18 becomes the minimum required version.
When replace is true, TypeScript requires a complete state object; incomplete replacements such as store.setState({}, true) are invalid.
TypeScript 4.5 becomes the minimum required version.
UMD and SystemJS support is dropped.
This package becomes a peer dependency, required for createWithEqualityFn and useStoreWithEqualityFn in zustand/traditional.
New APIs and options 4
The new option enables dispatching store actions directly from Redux DevTools.
An experimental middleware is available for a new usage with Next.js.
Use createWithEqualityFn from zustand/traditional when a custom equality function is needed or v4 behavior is required.
The useShallow hook provides a stable reference for selector results, including the shallow-equality use case.
Performance 1
useStore no longer memoizes getServerSnapshot.
Behavior and default changes 4
The middleware supports nested actions and arguments when dispatching store actions from Redux DevTools.
It now returns a native Promise<void> that can be awaited to ensure hydration is complete.
The middleware now supports PromiseLike results from storage reads, migrations, and migration writes.
Selectors that return a new reference may cause infinite loops; selector results should be stable.
Tooling 2
Improves typing in the devtools middleware.
Package entry points are reorganized in package.json.
Fixes and other changes 13
Shared devtools connections are preserved during store cleanup.
External devtools action arguments are preserved.
Devtools message parsing now applies serialize.reviver.
clearStorage() now invalidates concurrent asynchronous rehydration.
Corrected the V8 stack regex when a source path contains spaces.
Improves type inference for the Devtools initializer.
Supports Firefox and Safari stack formats when finding the caller name in devtools middleware.
Corrected the Redux DevTools configuration type extension.
The post-rehydration callback now uses the latest state.
Fixes immer middleware typing when used in combination with slices.
The persist middleware no longer relies on global localStorage.
Fixes a race condition during concurrent rehydrate calls in the persist middleware.
Immer type inference for setState is fixed.
zustand 423 changes
Breaking changes 20
The TypeScript signature changes to a curried form for explicit state types: replace create<T, ...>(...) with create<T>()(...).
The generic parameter now represents the store type; replace createContext<T>() with createContext<StoreApi<T>>().
v4 exposes createStore for more flexible context usage and exports it from vanilla.
Devtools deprecations and warnings were removed.
The devtools middleware now uses the official devtools extension types.
Higher kinded mutator types were added.
The devtools middleware no longer checks the old string option.
The type now accepts only T and represents Partial<T> or a function returning Partial<T>; replace PartialState<T, ...> with PartialState<T>.
Deprecated persist options were dropped in v4.
The TypeScript signature adds mutator type parameters; remove explicit type parameters and annotate only the action parameter.
removeItem is now required.
The type parameters now describe input and output mutators and the return type, changing annotations for middleware and slices.
The deprecated store.subscribe API with a selector was dropped.
v4 depends on use-sync-external-store; the notes warn that this might cause bundling issues.
The type now takes a store type; replace UseBoundStore<T> with UseBoundStore<StoreApi<T>>, and UseBoundStore<T, S> with UseBoundStore<S>.
This type is removed; use typeof MyContext.useStore instead.
The TypeScript signature now takes the store type as its first type parameter; remove explicit type parameters or pass the store type instead of the state type.
v4 exposes useStore as part of its more flexible API for context usage.
The deprecated UseStore type was dropped.
Compatibility with v2 hooks was dropped.
New APIs and options 2
The devtools middleware gained an enabled option, and shows its warning only if enabled.
The persist API gained a getOptions method.
Fixes and other changes 1
The partialized-state type is now T rather than Partial<T>, matching the identity default partialize; runtime behavior is unchanged.