CodeVetter · Repo Unpack · Feature catalog
pmndrs/zustand
The principal user-facing surface is a library API for creating, reading, updating, and subscribing to stores. Equality helpers and middleware provide optional behavior without changing the basic store model. The examples demonstrate counters, snippet selection and copying, and an interactive graphical backdrop.
- createStore supports direct and curried initialization; create returns a React hook with the imperative store API attached, and useStore can consume an existing store.
- createWithEqualityFn supplies a default comparator, and useStoreWithEqualityFn accepts a per-call selector and equality function.
- subscribeWithSelector adds slice subscriptions, custom equalityFn, previous-slice arguments, and fireImmediately while retaining whole-state subscriptions.
- persist supports partialize, version migration, custom merge, hydration callbacks, skipHydration, and an imperative persist API for rehydration, options, listeners, and storage clearing.
- devtools records named actions, groups stores by connection, supports time travel/import/reset messages, and exposes cleanup; redux adds reducer-backed dispatch to state and the store API.
- immer accepts draft-mutating updater functions, combine merges initial data with creator output, and unstable_ssrSafe replaces setters with throwing functions in SSR mode.
- shallow compares matching-prototype objects and iterable values; useShallow reuses the preceding selected value when that comparison succeeds.
- Examples provide increment buttons, JavaScript/TypeScript snippet selection, clipboard copying with success feedback, and a pointer-responsive Three.js scene with an image fallback.