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. 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/URL state → router search params (Vite app without Router: nuqs); never duplicate it in Zustand |
| Small, synchronous client state | Auth session → skill tanstack-start-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.