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

zustand-store-ts

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.

Skill link

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

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

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.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

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.”

5 new skills a week. 1 minute to read.

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.

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
#6244
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills