Skip to content
Skillpedia
Websites & UI (frontend)48k · #4630

zustand-store-ts

Creates state managers (stores) with Zustand and TypeScript. It helps organize user interface data efficiently and safely.

What it does

This code helps create a data 'store' for your web application using the Zustand library. It organizes how data is kept and how you can access and modify it, ensuring everything works correctly with TypeScript.

When to use it

  • ✓When you need to store information that many parts of your application will use.
  • ✓When building a state management system for your project.
  • ✓To organize global data that changes over time.

Example of what to ask your AI

“Create a store to manage a shopping cart's state, including items and the total, with functions to add and remove items.”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/zustand-store-ts/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/zustand-store-ts/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

It uses a pattern to define what to store (state) and what to do with that data (actions). It also ensures that only the necessary parts of your application update when the data changes.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add sickn33/agentic-awesome-skills --skill zustand-store-ts

Or download just the file:

curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/zustand-store-ts/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

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.

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
FAQ

What is 'Zustand'?

Zustand is a library that makes it easier to manage data in web applications.

What is 'TypeScript'?

TypeScript is a programming language that adds extra checks to help prevent errors in your code.

What is 'middleware'?

Middleware are like 'plugins' that add extra features to your store, such as logging changes or handling asynchronous actions.

Details

Original description by the author

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

repo: sickn33/agentic-awesome-skills

Popularity

GitHub stars
48k
Ranking position
#4630
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills