HAND-TAGGED >>> 991 SKILLS LIVE <<<* OPEN SOURCE *NO LOGIN, NO TRACKING FRESH DROPS WEEKLY HAND-TAGGED >>> 991 SKILLS LIVE <<<* OPEN SOURCE *NO LOGIN, NO TRACKING FRESH DROPS WEEKLY HAND-TAGGED >>> 991 SKILLS LIVE <<<* OPEN SOURCE *NO LOGIN, NO TRACKING FRESH DROPS WEEKLY HAND-TAGGED >>> 991 SKILLS LIVE <<<* OPEN SOURCE *NO LOGIN, NO TRACKING FRESH DROPS WEEKLY HAND-TAGGED >>> 991 SKILLS LIVE <<<* OPEN SOURCE *NO LOGIN, NO TRACKING FRESH DROPS WEEKLY HAND-TAGGED >>> 991 SKILLS LIVE <<<* OPEN SOURCE *NO LOGIN, NO TRACKING FRESH DROPS WEEKLY
← back to homepage
zustand-store-tsSKILL #E-TS
Coding

zustand-store-ts

Create Zustand stores following established patterns with proper TypeScript types and middleware.

↗ github · ★ 28k·src: davila7/claude-code-templates

the manual

Zustand Store

Create Zustand stores following established patterns with proper TypeScript types and middleware.

Quick Start

Copy the template from assets/template.ts and replace placeholders:

  • {{StoreName}} → PascalCase store name (e.g., Project)
  • {{description}} → Brief description for JSDoc

Always Use subscribeWithSelector

import { create } from 'zustand';
import { subscribeWithSelector } from 'zustand/middleware';

export const useMyStore = create<MyStore>()(
  subscribeWithSelector((set, get) => ({
    // state and actions
  }))
);

Separate State and Actions

export interface MyState {
  items: Item[];
  isLoading: boolean;
}

export interface MyActions {
  addItem: (item: Item) => void;
  loadItems: () => Promise<void>;
}

export type MyStore = MyState & MyActions;

Use Individual Selectors

// Good - only re-renders when `items` changes
const items = useMyStore((state) => state.items);

// Avoid - re-renders on any state change
const { items, isLoading } = useMyStore();

Subscribe Outside React

useMyStore.subscribe(
  (state) => state.selectedId,
  (selectedId) => console.log('Selected:', selectedId)
);

Integration Steps

  1. Create store in src/frontend/src/store/
  2. Export from src/frontend/src/store/index.ts
  3. Add tests in src/frontend/src/store/*.test.ts

When to Use

This skill is applicable to execute the workflow or actions described in the overview.

more coding

Request code reviews to catch issues early
Coding
HOT
Request code reviews to catch issues early
requesting-code-review
2@ 2 240k
Execute plans flawlessly and efficiently
Coding
HOT
Execute plans flawlessly and efficiently
executing-plans
0@ 0 240k
Finish your dev branch like a pro
Coding
HOT
Finish your dev branch like a pro
finishing-a-development-branch
0@ 0 240k
Verify feedback before you implement changes
Coding
HOT
Verify feedback before you implement changes
receiving-code-review
0@ 0 240k
Debug systematically to save time
Coding
HOT
Debug systematically to save time
systematic-debugging
0@ 0 240k
Write tests first, code with confidence
Coding
HOT
Write tests first, code with confidence
test-driven-development
0@ 0 240k
Build powerful MCP servers fast
Coding
HOT
Build powerful MCP servers fast
mcp-builder
0@ 1 156k
Transform messy data into clean spreadsheets
Coding
HOT
Transform messy data into clean spreadsheets
xlsx
0@ 0 156k