fe-zustand-store

Scaffold typed Zustand v5 stores for Next.js TypeScript applications.

Updated Apr 6, 2026
One-click install
npx skills add https://github.com/lety-ai/lety-skill-hub --skill fe-zustand-store
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fe-zustand-store
Source: https://github.com/lety-ai/lety-skill-hub/tree/main/plugins/zustand/skills/zustand
Command: npx skills add https://github.com/lety-ai/lety-skill-hub --skill fe-zustand-store

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill reduces friction when adding client-side state management by scaffolding well-typed Zustand v5 stores for Next.js TypeScript applications, ensuring consistent patterns for persistence, serialization, and reconstruction of non-serializable values.

Core Features & Use Cases

  • Non-persisted UI stores for modal flags, selections, loading states, and temporary UI data with separate State and Actions types and a reset function.
  • Persisted list and pagination stores using the persist middleware and partialize to persist only pagination meta and query parameters across refreshes.
  • Persisted stores with non-serializable values that use onRehydrateStorage to reconstruct class instances like CASL PureAbility while only persisting serializable parts.
  • Conventions & anti-patterns: enforce create API with explicit TypeScript types, define initialState constants, avoid storing server data in Zustand, and place files under features/<feature>/logic/store with -store.ts suffix.
  • Example: scaffold a projects list-store that persists current page and search query and reconstructs permissions on hydration.

Quick Start

Generate a TypeScript Zustand v5 persisted list store for the projects feature that persists paginationMeta and query using partialize and reconstructs non-serializable values with onRehydrateStorage.

Frequently Asked Questions about fe-zustand-store

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

FAQPage Schema
How do I persist Zustand store state in Next.js TypeScript applications?

To persist Zustand store state in Next.js TypeScript applications, use the persist middleware with partialize to select specific state slices for storage and onRehydrateStorage to rebuild non-serializable values upon loading.

How does onRehydrateStorage work with Zustand persist middleware?

The onRehydrateStorage callback in Zustand persist middleware triggers after storage rehydration, allowing you to reconstruct non-serializable class instances like CASL PureAbility that were excluded from the persisted serialized state.

What is the best way to structure Zustand stores in a Next.js feature folder?

The best way to structure Zustand stores in a Next.js feature folder is to place files under features/<feature>/logic/store with a -store.ts suffix, enforcing separate State and Actions TypeScript types.

Can I use Zustand for list pagination and query persistence in Next.js?

Yes, you can use Zustand for list pagination and query persistence in Next.js by applying the persist middleware with partialize to store only pagination metadata and query parameters across page refreshes.

When should I not use Zustand for state management in Next.js?

You should not use Zustand for state management in Next.js when handling server data, as this Skill explicitly enforces avoiding server data storage in Zustand to maintain proper client-side state boundaries.

Does this Zustand scaffolding approach support TypeScript explicitly?

Yes, this Zustand scaffolding approach supports TypeScript explicitly by enforcing the create API with distinct TypeScript State and Actions types, alongside defining initialState constants for robust typing.