zustand-5

Provide reusable Zustand 5 state management patterns for React applications.

Updated Mar 15, 2026
One-click install
npx skills add https://github.com/sebasmzg/sebas.dot --skill zustand-5-sebasmzg
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: zustand-5
Source: https://github.com/sebasmzg/sebas.dot/tree/main/.config/opencode/skill/zustand-5
Command: npx skills add https://github.com/sebasmzg/sebas.dot --skill zustand-5-sebasmzg

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Zustand 5 patterns reduce boilerplate and prevent inefficient re-renders by providing clear, reusable approaches to local state management in React applications.

Core Features & Use Cases

  • Typed stores: TypeScript examples for counters, todos, user and settings stores.
  • Persistence & Middleware: Guidance for using persist, immer, and devtools middleware to maintain state across sessions and enable safe mutations and debugging.
  • Selectors & Performance: Techniques to select specific fields or shallowly pick multiple fields to avoid unnecessary re-renders.
  • Slices & Composition: Patterns for composing independent slices (user, cart, etc.) into a single unified store.
  • Async and External Usage: Examples for async actions (fetching) and accessing or subscribing to the store outside React components.

Quick Start

Create a typed counter store with increment, decrement, and reset methods, enable persistence for settings, and demonstrate a selector-based React component that reads only the count.

Frequently Asked Questions about zustand-5

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

FAQPage Schema
How do I manage React state with Zustand 5 without causing unnecessary re-renders?

Zustand 5 manages local store state cleanly and prevents inefficient re-renders by using selectors to target specific fields or shallowly pick multiple fields, ensuring components only re-render when their selected state changes.

How do I configure persist middleware in a TypeScript Zustand store?

Configuring persist middleware in a TypeScript Zustand store maintains state across sessions. You apply the persist middleware to your typed store definition, enabling automatic state hydration and local storage synchronization for client-side React projects.

Can I use Immer with Zustand 5 for safe state mutations?

Yes, applying the immer middleware to a Zustand 5 store enables safe mutations. This allows you to write standard mutable syntax directly inside store actions while Immer safely handles the underlying immutable state updates.

What is the best way to compose independent state slices into a single Zustand store?

The best way to compose independent state slices into a single Zustand store is using slice composition patterns. This approach combines independent stores like user and cart slices into one unified store, maintaining predictable local state management.

How do I access and subscribe to a Zustand store outside of React components?

You can access and subscribe to a Zustand store outside of React components by calling the store directly. Zustand provides external usage capabilities, allowing you to retrieve state and subscribe to updates for async actions or external logic.

Does Zustand 5 support async data fetching within store actions?

Yes, Zustand 5 supports async data fetching within store actions. You can define asynchronous actions inside your typed store to handle data fetching, updating the store state predictably once the async operations resolve.