π»
Zustand
IntermediateA small, fast, and scalable state management solution β minimal API, no boilerplate
Zustand vs Redux
Zustand: ~1KB, no Provider needed, no actions/reducers, call store methods directly. Redux: larger ecosystem, DevTools, strict patterns. Use Zustand for most local/medium-complexity state, Redux when you need time-travel debugging, strict unidirectional flow, or team conventions. Install:npm i zustandBasic Store β create()
beginnerCreate a store with state + actions in one place. No Provider, no dispatch, no actions. Access state and methods directly.
Persist Middleware β Survives Refresh
intermediateThe persist middleware syncs your store with localStorage (or sessionStorage) automatically. State rehydrates on page load.
Immer Middleware β Mutable Syntax
intermediateThe immer middleware lets you write mutable code (like Redux Toolkit) while Immer ensures immutability behind the scenes.
subscribeWithSelector & Slice Pattern
advancedsubscribeWithSelector enables reactive subscriptions to specific state slices. The slice pattern splits large stores into composable modules.