Skip to content
Back to skills

Zustand

ASecurity

Zustand — lightweight state management with stores, selectors, middleware, slices pattern.

  • 47 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 12, 2026
toolsreact

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add skeletorflet/opencode-supreme-setup --skill zustand --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Zustand?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Zustand
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/skeletorflet-zustand/badge)](https://www.skillsdirectory.com/skills/skeletorflet-zustand)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.