zustand

Guide Zustand state management and slice organization for React and Next.js stores.

Updated Apr 7, 2026
One-click install
npx skills add https://github.com/rally19/goform --skill zustand-rally19
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: zustand
Source: https://github.com/rally19/goform/tree/main/.qwen/skills/zustand
Command: npx skills add https://github.com/rally19/goform --skill zustand-rally19

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Provides clear patterns and conventions for organizing and maintaining Zustand stores to reduce bugs, inconsistent action naming, and brittle state updates in React projects.

Core Features & Use Cases

  • Action hierarchy & naming: Defines public, internal, and dispatch action naming and responsibilities to keep UI and business logic separated.
  • Reducer vs set guidance: Explains when to use reducer patterns for complex lists/maps and when to use simple set operations for primitive updates.
  • Optimistic update patterns: Documents safe optimistic update flows, when to avoid optimism (destructive deletes), and refresh strategies.
  • Class-based slice composition: Shows how to migrate to class-based action implementations, use private fields, and compose slices with flattenActions for large stores.
  • Slice organization & selectors: Recommends file layout, state shapes, selectors, and SWR integration patterns for caching and refresh.

Quick Start

Review the src/store directory and recommend slice organization, reducer versus set choices, action naming, and optimistic update patterns for messages and topics.

Frequently Asked Questions about zustand

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I organize Zustand store slices in a React project?

Organize Zustand slices by defining file layout, state shapes, and selectors within the src/store directory. Separate UI from business logic by establishing public, internal, and dispatch action naming responsibilities to reduce bugs and inconsistent updates.

When should I use reducers versus set operations for Zustand state management?

Use reducer patterns for Zustand state management when handling complex lists and maps, and use simple set operations for primitive updates. This guidance helps prevent brittle state updates and maintains consistent action behavior across React projects.

What is the best way to implement optimistic updates in Zustand?

Implement safe optimistic updates in Zustand by following documented flows, avoiding optimism for destructive deletes, and establishing refresh strategies. Apply these patterns to messages and topics to prevent inconsistent state during network failures.

Can I use class-based slice composition for large Zustand stores?

Yes, you can migrate large Zustand stores to class-based slice composition by using private fields and composing slices with flattenActions. This approach maintains structure and scalability when implementing actions and reducers in React.

Does Zustand work with SWR for state caching and refresh in Next.js?

Zustand works with SWR by integrating selector and initialization patterns to manage state caching and refresh strategies in Next.js. This combination maintains local state conventions while leveraging SWR for remote data fetching.