zustand-store-ts

Create typed Zustand v5 stores with separated state and actions.

1|Updated Feb 24, 2026
One-click install
npx skills add https://github.com/devsepnine/hibi_ai --skill zustand-store-ts-devsepnine
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: zustand-store-ts
Source: https://github.com/devsepnine/hibi_ai/tree/main/src/skills/zustand
Command: npx skills add https://github.com/devsepnine/hibi_ai --skill zustand-store-ts-devsepnine

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes assets (resource) and references (resource) components.

What problem does it solve?

Zustand v5 stores require clear structure and typing to avoid runtime issues; this skill provides patterns to organize state and actions, selectors, and middleware for scalable React apps.

Core Features & Use Cases

  • Explicit state and action separation for maintainability and testability
  • Safe selector patterns using useShallow to prevent infinite renders
  • Integration with devtools, persist, and slices for scalable stores
  • Guidance for migrating from v4 and building modular stores

Quick Start

Copy the template from assets/template.md and replace placeholders with your store name.

Frequently Asked Questions about zustand-store-ts

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

FAQPage Schema
How do I structure a Zustand v5 store with TypeScript to separate state and actions?

To structure a Zustand v5 store with TypeScript, enforce a clear separation of state and actions within your store definition. This pattern improves maintainability and testability by keeping state mutations explicitly named for devtools tracing.

Why does my Zustand selector cause infinite renders in React and how do I fix it?

Zustand selectors cause infinite renders when returning new object references on each call. Fix this by applying the useShallow selector pattern to perform shallow comparisons, preventing unnecessary re-renders and stabilizing component updates.

What is the best way to scale large Zustand stores using slices?

The best way to scale large Zustand stores is by composing modular slices. This pattern allows you to split state and actions into isolated segments, integrating devtools and persist middleware for robust production workflows.

Does Zustand v5 work with subscribeWithSelector for external subscriptions?

Yes, Zustand v5 supports external subscriptions via the subscribeWithSelector middleware. This allows you to subscribe to specific state changes and fire callbacks with strict typing, enabling fine-grained reactive logic outside of React components.

How do I properly chain Zustand middleware with strict TypeScript typing?

Properly chaining Zustand middleware in TypeScript requires explicit type definitions for each middleware layer, such as devtools and persist. This ensures strict typing across the entire middleware pipeline and prevents runtime type mismatches.

Can I use Zustand devtools and persist middleware together in production?

Yes, you can integrate Zustand devtools and persist middleware together for production workflows. This combination allows you to trace explicit named actions while automatically persisting your application state across sessions.