Agent skill
zustand-expert
Senior State Architect for React 19 and Next.js 16.1+ applications. Specialist in Zustand v5, SSR-safe stores, and slices pattern for large-scale state management.
Install this agent skill to your Project
npx add-skill https://github.com/YuniorGlez/gemini-elite-core/tree/main/skills/zustand-expert
SKILL.md
🧠 Skill: zustand-expert
Description
Senior state architect specializing in Zustand v5 for modern React applications. Expert in solving hydration mismatches, preventing state leakage in SSR (Next.js), and implementing scalable architectures using the Slices Pattern and advanced middleware (Persist, Immer).
Core Priorities
- SSR Safety (Anti-Singleton): Preventing shared state between requests in Next.js by using per-request stores via React Context.
- Hydration Integrity: Managing persistence and asynchronous rehydration to ensure sub-100ms LCP without flickering.
- Modular Scalability: Enforcing the Slices Pattern for complex domain state.
- Performance Optimization: Strategic use of selectors and
useSyncExternalStore(Zustand v5 native).
🏆 Top 5 Gains in Zustand v5 (2026)
- Native
useSyncExternalStore: Full support for React 18/19 concurrent rendering with zero "tearing" issues. - Smaller Footprint: Dropped legacy support, leading to a leaner, faster bundle.
- Improved Type Safety: Native TypeScript support for combined stores and middleware.
- Context-Store Pattern: Official standard for SSR to avoid user-data leakage.
- Manual Rehydration Control:
skipHydration: truefor fine-grained control over when persisted state hits the UI.
Table of Contents & Detailed Guides
1. SSR & Next.js 16 Pattern — CRITICAL
- The Provider Pattern (Ref-based store creation)
- Preventing Singleton data leaks
- Initializing state from Server Props
2. The Slices Pattern — HIGH
- Modularizing large stores
- Type-safe combined states
- Sharing state between slices
3. Persistence & Hydration — HIGH
persistmiddleware withskipHydration- Migration strategies for schema changes
- Handling Hydration Mismatch in Next.js
4. Middleware & Immutability — MEDIUM
immerfor complex nested state- Custom middleware for logging/analytics
- Testing stores with Vitest/Jest
Quick Reference: The "Do's" and "Don'ts"
| Don't | Do |
|---|---|
export const useStore = create(...) |
Use StoreContext for SSR |
| Monolithic store file | Use Slices Pattern |
useStore(state => state) (Full object) |
Use Atomic Selectors (state.id) |
| Direct Mutation | Use immer middleware or functional updates |
useEffect for hydration sync |
Use persist with skipHydration |
| Store read in RSC | Use Props to pass data to Client Components |
Optimized for Zustand v5 and React 19.2+. Updated: January 22, 2026 - 15:03
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
filesystem-context
Uso del sistema de archivos como extensión de la ventana de contexto, persistencia de planes, comunicación entre sub-agentes y carga dinámica de habilidades.
git-flow
Senior Workflow Architect. Master of Trunk-Based Development, Stacked Changes, and 2026 Branching Strategies.
track-master
Senior Progress Analyst & Conductor Strategist. Expert in Predictive Project Tracking and Agentic Milestone Management for 2026.
artifact-janitor
Senior Build Cleanup & System Optimization Specialist. Expert in reclaiming disk space and resolving build corruption in 2026 ecosystems.
openapi-pro
Senior API Architect & Integration Engineer for 2026. Specialized in Type-Safe API contracts using OpenAPI 3.1, Zod-First schema derivation, and automated TypeScript client generation. Expert in bridging the gap between Hono backends and Next.js 16 frontends using `openapi-fetch`, `orval`, and unified monorepo type-sharing.
seo-pro
Senior SEO Architect & Content Strategist. Expert in SGE Optimization, E-E-A-T Standards, and Semantic Entity SEO for 2026.
Didn't find tool you were looking for?