zustand-state-management
Installation
SKILL.md
LLM reference: Fetch llms.txt for the documentation index and latest API. Full docs: llms-full.txt. Human-readable docs: zustand.docs.pmnd.rs.
Core mental model: Working with Zustand (Dominik Dorfmeister) — export custom hooks only, atomic selectors, actions namespace, event-style actions, many small stores, combine with Query/URL via custom hooks.
Version: Zustand v5 (create<T>()(), useShallow from zustand/shallow). Pin zustand@^5 in the app; check migrating to v5 when upgrading.
When to use Zustand
| Use Zustand for | Use something else for |
|---|---|
| Client UI state shared across components (panels, map tools, wizard steps) | Server data → TanStack Query |
| Ephemeral client prefs not in the URL | Shareable/bookmarkable state → nuqs |
| Small, synchronous client state | Auth session → app auth skill / Better Auth |
Most app state is server or URL state. Add a Zustand store only when you need client-global state that is not already covered.