
Zustand 5
This covers Zustand 5's state management patterns with all the essentials: basic stores, the persist middleware for localStorage, proper selector usage with useShallow to avoid unnecessary re-renders, async actions, the slices pattern for organizing larger stores, and Immer middleware for simpler immutable updates. The examples are practical and show the common pitfalls, like selecting the entire store instead of specific fields. If you're building a React app and need client-side state that's lighter than Redux but more structured than useState, this gives you the modern patterns. The slice composition approach is especially useful once your stores grow beyond a handful of fields and actions.
- skills.sh installs
- 911
- GitHub stars
- 15.2K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add prowler-cloud/prowler --skill zustand-5 --agent claude-codeInstalls into .claude/skills of the current project.
Files
Prowler UI Layout
- Stores live in
ui/store/{feature}/store.ts(some single files, e.g.ui/store/side-panel.ts) and are re-exported fromui/store/index.ts. - Tests:
ui/store/__tests__/*.test.tsor co-locatedstore.test.ts. zustand/middleware(persist,createJSONStorage) is used;immeris NOT installed inui/.
Basic Store
import { create } from "zustand";
interface CounterStore {
count: number;
increment: () => void;
decrement: () => void;
reset: () => void;
}
const useCounterStore = create<CounterStore>((set) => ({
count: 0,
increment: () => set((state) => ({ count: state.count + 1 })),
decrement: () => set((state) => ({ count: state.count - 1 })),
reset: () => set({ count: 0 }),
}));
// Usage - select what you need
function Counter() {
const count = useCounterStore((s) => s.count);
const increment = useCounterStore((s) => s.increment);
const decrement = useCounterStore((s) => s.decrement);
return (
<div>
<span>{count}</span>
<button onClick={increment}>+</button>
<button onClick={decrement}>-</button>
</div>
);
}
Persist Middleware
Sponsors
Details
- Repository
- github.com/prowler-cloud/prowler
- Categories
- Frontend Development, Backend & APIs, Cloud & Infrastructure
- First seen
- Jun 3, 2026