MCPInstall

zustand

Zustand v5 state management for React. Covers TypeScript stores with double-parentheses syntax, persist middleware with hydration handling, devtools, subscribeWithSelector, slices pattern for large apps, SSR/Next.js provider pattern, immer middleware, auto-generating selectors, testing, and vanilla stores. Use when setting up global state, configuring persist middleware, implementing slices pattern, migrating from Redux or Context, testing stores, or troubleshooting hydration and TypeScript issues.

Installs
146
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/oakoss/agent-skills --skill zustand
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads zustand automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Zustand State Management

Overview

Zustand v5 is a lightweight global state manager for React built on useSyncExternalStore. Requires React 18+ (uses useSyncExternalStore internally). When using createWithEqualityFn, install use-sync-external-store as a peer dependency. It provides type-safe stores, atomic selectors for minimal re-renders, composable middleware (persist, devtools, immer, subscribeWithSelector), and a slices pattern for large applications. Use Zustand for client-only global state; use TanStack Query for server-fetched data.

When to use: Client-side global state, persistent user preferences, complex multi-domain stores, cross-component state sharing, vanilla (non-React) state management.

When NOT to use: Server state with caching needs (use TanStack Query), single-component state (use useState), simple prop drilling scenarios.

Quick Reference

PatternAPIKey Points
Basic storecreate<T>()((set) => ({...}))Double parentheses required for TS
Atomic selectoruseStore(state => state.bears)Only re-renders when selected value changes
Multiple valuesuseShallow(state => ({a, b}))Import from zustand/react/shallow
Persistpersist(fn, { name })localStorage with SSR hydration handling
Devtoolsdevtools(fn, { name })Redux DevTools integration
SubscribeWithSelectorsubscribeWithSelector(fn)Subscribe to state slices outside React
Middleware orderdevtools(persist(fn))Outer to inner wrapping
Slices patternStateCreator<Combined, [], [], Slice>Split store by domain
SSR providercreateStore + React ContextPer-request stores prevent data leaks
Immerimmer(fn)Safe nested state mutations
Vanilla storecreateStore from zustand/vanillaUse outside React
Reset storeset(store.getInitialState())Use getInitialState() for reliable reset
Derived valuesuseStore(s => s.items.length)Compute in selector
Auto selectorscreateSelectors(store)Generate store.use.field() hooks automatically

Common Mistakes

MistakeCorrect Pattern
Using create<T>(...) with single parenthesesUse create<T>()(...) double parentheses for correct TypeScript middleware inference
Selecting full state object with useStore(state => state)Use atomic selectors like state.bears or useShallow to avoid unnecessary re-renders
Importing useShallow from zustand/shallowImport from zustand/react/shallow; zustand/shallow exports the plain shallow function only
Creating new object references in selectors causing infinite loopsUse separate primitive selectors or wrap with useShallow from zustand/react/shallow
Using a global singleton store with SSR or Next.jsUse the StoreContext provider pattern with createStore to prevent data leaks between requests
Tracking initial state manually for resetUse store.getInitialState() which Zustand provides automatically
Using Zustand for server-fetched data that needs caching and revalidationUse TanStack Query for server state; reserve Zustand for client-only global state

Delegation

  • Store architecture and slices design: Use Plan agent to define domain boundaries, slice interfaces, and middleware composition order
  • Hydration and SSR debugging: Use Task agent to diagnose persist middleware issues, hydration mismatches, and Next.js provider setup
  • Migration from v4 to v5: Use Explore agent to find deprecated import paths, single-parentheses patterns, and legacy middleware usage
  • Testing strategy: Use Task agent to set up store mocks and test isolation patterns

References

  • Store patterns, TypeScript, and core API
  • Middleware: persist, devtools, immer, subscribeWithSelector, and custom
  • Slices pattern and large store architecture
  • SSR, Next.js, and hydration handling
  • Testing stores with Vitest and Jest
  • Migration guide: Redux, Context, and v4 to v5

FAQ

What does the zustand skill do?

Zustand v5 state management for React. Covers TypeScript stores with double-parentheses syntax, persist middleware with hydration handling, devtools, subscribeWithSelector, slices pattern for large apps, SSR/Next.js provider pattern, immer middleware, auto-generating selectors, testing, and vanilla stores. Use when setting up global state, configuring persist middleware, implementing slices pattern, migrating from Redux or Context, testing stores, or troubleshooting hydration and TypeScript issues.

How do I install zustand?

Run npx skills add https://github.com/oakoss/agent-skills --skill zustand in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/zustand/ (personal) or .claude/skills/zustand/ (project).

Which AI agents can use zustand?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is zustand safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains zustand?

It is published by oakoss in oakoss/agent-skills. It has 146 recorded installs.

More from oakoss/agent-skills

View all →

ui-ux-polish

oakoss/agent-skills

Iterative UI/UX polishing workflow for web applications. Use when improving visual polish, refining desktop and mobile UX separately, running iterative enhancement cycles, applying design patterns like glassmorphism or bento grids, or auditing accessibility and WCAG compliance. Use for Stripe-level visual quality, responsive optimization, and design system alignment.

Frontend & Design541 installs

playwright

oakoss/agent-skills

Open the skill to read its SKILL.md instructions.

Testing & QA453 installs

coolify

oakoss/agent-skills

Coolify self-hosted PaaS for deploying applications, databases, and services via REST API and Git integration. Covers API authentication, deployment triggers, build packs (Nixpacks, Dockerfile, Compose), CI/CD with GitHub Actions webhooks, environment management, and Traefik proxy configuration. Use when deploying apps to Coolify, triggering deployments via API, configuring build packs, setting up GitHub Actions CI/CD pipelines, managing environment variables, or troubleshooting deployment failures.

DevOps & Cloud361 installs

application-security

oakoss/agent-skills

Open the skill to read its SKILL.md instructions.

Security272 installs

find-skills

oakoss/agent-skills

Open the skill to read its SKILL.md instructions.

AI & Agents255 installs

drizzle-orm

oakoss/agent-skills

Open the skill to read its SKILL.md instructions.

Data & Databases238 installs

Popular frontend & design skills

View category →

setup-matt-pocock-skills

mattpocock/skills

Configure this repo for the engineering skills: set up its issue tracker, triage label vocabulary, and domain doc layout. Run once before first use of the other engineering skills.

Frontend & Design1.1M installs

frontend-design

anthropics/skills

Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.

OfficialFrontend & Design1M installs

hyperframes-animation

heygen-com/hyperframes

All animation knowledge for HyperFrames — atomic motion rules, multi-phase scene blueprints, scene transitions, broader motion-design techniques, AND the seven runtime adapters (GSAP default, plus Lottie, Three.js, Anime.js, CSS keyframes, Web Animations API, TypeGPU). Use for any motion or animation task: pick 2-4 rules and compose, or load a blueprint, or look up runtime-specific API (e.g. GSAP eases / Lottie player / Three.js mixer). Also covers auditing an existing composition's choreography (animation map) and 24 named text-animation effects. HyperFrames-native: single paused timeline, seek-safe, deterministic.

prototype

mattpocock/skills

Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.

Frontend & Design999.2K installs

hyperframes-core

heygen-com/hyperframes

The HyperFrames composition contract — build one renderable project. Use for composition structure, the data- timing attributes, class="clip", tracks, sub-compositions, variables, framework-owned media playback, deterministic-render rules, and validation. Read before writing composition HTML.

Frontend & Design930.5K installs

vercel-react-best-practices

vercel-labs/agent-skills

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

OfficialFrontend & Design843.1K installs