Esta página se muestra en inglés. Una traducción al español está en curso.
SkillsApr 11, 2026·2 min de lectura

Zustand — Bear-Sized State Management for React

Zustand is a small, fast, and scalable bearbones state-management solution for React. A cozy alternative to Redux with a simple hooks API, no providers needed, and first-class TypeScript support.

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
step-1.md
Comando de instalación directa
npx -y tokrepo@latest install 2f0e010c-3567-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con dry-run.

TL;DR
Zustand provides small, fast state management for React using a hooks API with no providers and full TypeScript support.
§01

What it is

Zustand is a lightweight state management library for React. It uses a simple hooks-based API, requires no context providers, and supports TypeScript out of the box. At under 1KB gzipped, it is one of the smallest state management solutions available.

Zustand targets React developers who want global state without the boilerplate of Redux or the complexity of context-based solutions.

§02

How it saves time or tokens

Zustand eliminates provider wrappers, action creators, reducers, and dispatch patterns. You define a store in one function call and consume it with a hook. No selectors library, no middleware setup, no normalized state shape required.

§03

How to use

  1. Install Zustand:
npm i zustand
  1. Create a store:
import { create } from 'zustand';

type BearStore = {
  bears: number;
  increase: () => void;
  reset: () => void;
};

export const useBearStore = create<BearStore>((set) => ({
  bears: 0,
  increase: () => set((s) => ({ bears: s.bears + 1 })),
  reset: () => set({ bears: 0 }),
}));
  1. Use in any component — no provider needed:
function Counter() {
  const bears = useBearStore((s) => s.bears);
  const increase = useBearStore((s) => s.increase);
  return <button onClick={increase}>{bears} bears</button>;
}
§04

Example

import { create } from 'zustand';

interface TodoStore {
  todos: string[];
  add: (todo: string) => void;
  clear: () => void;
}

const useTodoStore = create<TodoStore>((set) => ({
  todos: [],
  add: (todo) => set((s) => ({ todos: [...s.todos, todo] })),
  clear: () => set({ todos: [] }),
}));

// Use anywhere without wrapping in a Provider
function TodoList() {
  const todos = useTodoStore((s) => s.todos);
  return <ul>{todos.map((t) => <li key={t}>{t}</li>)}</ul>;
}
§05

Related on TokRepo

Key considerations

When evaluating Zustand for your workflow, consider the following factors. First, assess whether your team has the technical prerequisites to adopt this tool effectively. Second, evaluate the maintenance burden against the productivity gains. Third, check community activity and documentation quality to ensure long-term viability. Integration with your existing toolchain matters more than feature count alone. Start with a small pilot project before rolling out across the organization. Monitor resource usage during the initial adoption phase to identify bottlenecks early. Document your configuration decisions so team members can onboard independently.

§06

Common pitfalls

  • Selecting the entire store object (no selector function) causes unnecessary re-renders; always use selector functions.
  • Zustand stores are singletons; in SSR frameworks like Next.js, use per-request store creation to avoid data leaking between users.
  • Middleware (persist, devtools) must be applied at store creation time; they cannot be added later.

Preguntas frecuentes

How does Zustand compare to Redux?+

Zustand is much simpler. No action types, reducers, or dispatch. You define state and actions in one function. Redux offers more structure and middleware ecosystem for large applications. Zustand is better for small to medium state needs.

Does Zustand work with Next.js?+

Yes. Zustand works with Next.js, but SSR requires care. Create stores per-request to avoid sharing state between users. The Zustand documentation covers Next.js patterns specifically.

Is Zustand type-safe?+

Yes. Zustand has first-class TypeScript support. Define your store type and Zustand infers selector return types, action parameters, and state shape automatically.

Can I persist Zustand state?+

Yes. Zustand's persist middleware saves state to localStorage, sessionStorage, or any custom storage adapter. State is automatically rehydrated when the app loads.

How small is Zustand?+

Zustand is under 1KB gzipped. It has no dependencies beyond React. This makes it one of the smallest state management libraries available for React.

Referencias (3)

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados