zustand-docs
Skill2 starsChanged 17 days agoMITView on GitHub
Referencia completa de Zustand v5 para manejo de estado global en el cliente con Next.js 16. Úsala cuando trabajes con: creación de stores, slices pattern, middleware (persist, devtools, immer), uso en Server Components, hidratación SSR, stores tipados con TypeScript, o cuando debas decidir entre Zustand, Context API o TanStack Query para un problema de estado. También activa para: estado de UI (modals, sidebars, notificaciones), estado de sesión del cliente, o carrito de compras en sistemas POS/ecommerce.
In this repository31 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- private-template/CLAUDE.mdCLAUDE.md
- backend-quality-gateSkill
- blindarSkill
- brechasSkill
- crear-appSkill
- desarrollo-por-etapasSkill
- docker-docsSkill
- elegir-metodoSkill
- erp-saas-coreSkill
- fullstackSkill
- graphifySkill
- http-query-docsSkill
- mapa-bloqueSkill
- memory-bank-contextSkill
- mem-searchSkill
- microserviciosSkill
- minio-docsSkill
- nestjs-docsSkill
- nestjs-security-hardeningSkill
- nextjs-docsSkill
- prisma7-docsSkill
- prompt-masterSkill
- react-docsSkill
- redis-docsSkill
- skills-bundleSkill
- tailwind-docsSkill
- tanstack-query-docsSkill
- testing-actionsSkill
- typescript-docsSkill
- ui-ux-polishSkill
The file
Files
Zustand v5 — Referencia Completa
Documentación oficial (Context7)
Para la doc oficial y actualizada de Zustand v5, consulta el MCP Context7 (resolve-library-id → query-docs) antes de generar código con APIs que no domines al 100%. Si contradice esta skill en una regla del estándar, gana la skill; si es un detalle de API, gana Context7.
Cuándo usar Zustand vs otras opciones
Zustand
✅ Estado UI compartido entre componentes no relacionados
✅ Estado que persiste entre navegaciones (cliente)
✅ Stores complejos con múltiples acciones
Context API (sin Zustand)
✅ Estado simple que cambia raramente (theme, locale)
✅ Solo necesita propagarse a componentes hijos directos
TanStack Query (no Zustand)
✅ Estado del servidor — datos que vienen de una API
✅ Cache, sincronización, background refetchPatrones esenciales
// Store tipado con TypeScript
interface CartStore {
items: CartItem[];
addItem: (item: CartItem) => void;
removeItem: (id: string) => void;
clear: () => void;
}
const useCartStore = create<CartStore>()((set) => ({
items: [],
addItem: (item) => set((state) => ({ items: [...state.items, item] })),
removeItem: (id) =>
set((state) => ({ items: state.items.filter((i) => i.id !== id) })),
clear: () => set({ items: [] }),
}));
// Con persist middleware
const useAuthStore = create<AuthStore>()(
persist((set) => ({ user: null, setUser: (user) => set({ user }) }), {
name: "auth-storage",
}),
);
// Slices pattern para stores grandes
const useStore = create<StoreState>()((...a) => ({
...createCartSlice(...a),
...createUISlice(...a),
}));Reglas no negociables
- No guardar datos del servidor en Zustand — eso va en TanStack Query
- Selectors para evitar re-renders:
const items = useCartStore(state => state.items) devtoolsmiddleware siempre en desarrollo para debugging- SSR con Next.js: inicializar stores con
createStore(nocreate) para evitar estado compartido entre requests
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

