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-code

Installs 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 from ui/store/index.ts.
  • Tests: ui/store/__tests__/*.test.ts or co-located store.test.ts.
  • zustand/middleware (persist, createJSONStorage) is used; immer is NOT installed in ui/.

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

More from prowler-cloud/prowler

All 6
1affaan-m avatarreact-patternsaffaan-m/everything-claude-codereact patterns893skills.sh installs
2affaan-m avatarfrontend-a11yaffaan-m/everything-claude-codefrontend a11y870skills.sh installs
3manutej avatarui-design-patternsmanutej/luxor-claude-marketplaceCommon interface patterns, navigation patterns, form patterns, data display patterns, feedback patterns, and accessibility considerations854skills.sh installs
4wot-ui avatarwot-ui-cliwot-ui/open-wot使用、调试或维护 @wot-ui/cli 与 open-wot 仓库。适用于 wot CLI 命令、Agent/MCP 接入、doctor/usage/lint、组件知识查询、客户端 adapter、离线数据提取、构建测试、发布包检查和仓库开发;如果任务是直接编写 wd-* 组件页面或解释组件 API,应改用 wot-852skills.sh installs
5molefrog avatarreact-pdfmolefrog/skillsGenerate PDF documents using React-PDF library (@react-pdf/renderer). Use when creating PDFs, generating documents, reports, invoices, forms, or when user menti761skills.sh installs
6sickn33 avatarstitch-ui-designsickn33/antigravity-awesome-skillsstitch ui design737skills.sh installs