Loading...
Loading...
Implement global state management for React/TypeScript applications. Use when creating, modifying, or debugging Zustand stores, implementing state management patterns (slices, persist, devtools, immer), setting up Zustand with Next.js/SSR, writing tests for Zustand stores, or working with TypeScript typing for Zustand (curried create, StateCreator, middleware mutators).
npx skill4agent add fellipeutaka/leon zustandimport { create } from "zustand"
interface BearState {
bears: number
increase: (by: number) => void
}
const useBearStore = create<BearState>()((set) => ({
bears: 0,
increase: (by) => set((state) => ({ bears: state.bears + by })),
}))
// In components — select only what you need
const bears = useBearStore((state) => state.bears)create<T>()(...)setuseShallowdevtoolsdevtools(persist(immer(...)))createStorecreate| Need | Solution |
|---|---|
| Basic React store | |
| Vanilla (non-React) store | |
| Use vanilla store in React | |
| Auto-infer types (no interface) | |
| Persist to localStorage | |
| Redux DevTools | |
| Mutable-style updates | |
| Subscribe to slices externally | |
| Multiple fields without rerender | |
| Large store modularization | Slices pattern with |
| Next.js App Router | |
| Reset store | |