Zustand — lightweight state management with stores, selectors, middleware, slices pattern.
Scanned 9/12/2026
Install to Claude Code
npx -y skills add skeletorflet/opencode-supreme-setup --skill zustand --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Zustand?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/skeletorflet-zustand)More formats (shields.io, HTML) on the badges page.
---
name: zustand
description: Zustand — lightweight state management with stores, selectors, middleware, slices pattern.
---
## zustand
### Stores & Actions
- `create((set, get) => ({ count: 0, inc: () => set((s) => ({ count: s.count + 1 })) }))` — define store.
- `set` for partial state merges; `get()` for current state inside actions.
- `set({ count: 5 }, true)` — replace entire state instead of shallow merge.
### Selectors
- `useStore((s) => s.count)` — subscribe with selector; re-renders only on change.
- `useStore.getState()` / `useStore.setState(...)` — read/write outside React.
- `subscribe((state) => console.log(state))` — listener for non-React contexts.
- `subscribe((s) => s.count, (count) => ...)` — selector-based subscription (v4+).
### Middleware
- `persist` — `persist(store, { name: 'key', storage: createJSONStorage(() => localStorage) })`.
- `immer` — `immer((state) => { state.items.push(newItem) })` — mutable-style updates.
- `devtools` — `devtools(store, { name: 'StoreName' })` — Redux DevTools integration.
- `subscribeWithSelector` — enables selector-specific subscriptions.
### Slices Pattern
- Compose stores: `create((...a) => ({ ...createUserSlice(...a), ...createCartSlice(...a) }))`.
- Each slice receives `set`, `get` — no cross-slice coupling.
- `useBoundStore` — re-export composed store with typed selectors.
### Computed Values
- Derive state in selectors: `useStore((s) => s.items.filter((i) => i.active))`.
- Use `subscribeWithSelector` + local computation for memoized derivations.
- Middleware `combine` or manual `get()` in actions for computed side effects.
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!