client-state-management
Installation
SKILL.md
Client-Side State Management
Decision: Library Selection
| Need | Use | Why |
|---|---|---|
| Simple shared state, <5 consumers | Context API | Zero dependencies, built-in |
| Medium complexity, performance matters | Zustand | 1.5kb, no boilerplate, auto re-render optimization |
| Large app, strict patterns needed | Redux Toolkit | DevTools, middleware ecosystem, time-travel |
| Fine-grained reactivity, atoms | Jotai | Bottom-up, minimal re-renders, composable |
| Server state (fetching/caching) | React Query or SWR | Deduplication, background refresh, cache |
Decision: Global vs Local State
Keep Local (useState/useReducer):
- Form input values before submission
- UI state (open/closed, hover, focus)
- Component-specific loading/error states