React State Management

SkillAI & models

react-state-management is a skill that helps an AI agent work with React state management. It covers Redux Toolkit, Zustand, Jotai, and React Query, and it is used when setting up global state, managing server state, or choosing between state management solutions. The agent can then set up and compare these approaches for your project.

Use React State Management in Claude, ChatGPT or Ahel Desktop

Free. Sign in, add React State Management and connect your AI. About a minute.

Also: Claude Code · Cursor · Codex

Then ask your AI: use the React State Management skill

Details

Instructions available. Your AI can read the instructions. Execution depends on the setup they require.

Have a React project that needs state management.

React State ManagementStart free

What your AI can do with it

  • Set up global state with Redux Toolkit, Zustand, or Jotai
  • Manage server state with React Query
  • Compare state management solutions for a given use case
  • Choose between global state and server state approaches
  • Apply modern React state management patterns

Getting started

  1. Have a React project that needs state management.
  2. Add the skill to your agent's available skills.
  3. Ask the agent to set up or compare state management approaches.
  4. Review the generated code and configuration in your project.

What this skill tells your AI

The instructions your AI receives, as published by wshobson/agents in plugins/frontend-mobile-development/skills/react-state-management/SKILL.md and read by ahel’s review.

Comprehensive guide to modern React state management patterns, from local component state to global stores and server state synchronization.

When to Use This Skill

  • Setting up global state management in a React app
  • Choosing between Redux Toolkit, Zustand, or Jotai
  • Managing server state with React Query or SWR
  • Implementing optimistic updates
  • Debugging state-related issues
  • Migrating from legacy Redux to modern patterns

Core Concepts

1. State Categories

TypeDescriptionSolutions
Local StateComponent-specific, UI stateuseState, useReducer
Global StateShared across componentsRedux Toolkit, Zustand, Jotai
Server StateRemote data, cachingReact Query, SWR, RTK Query
URL StateRoute parameters, searchReact Router, nuqs
Form StateInput values, validationReact Hook Form, Formik

2. Selection Criteria

Small app, simple state → Zustand or Jotai
Large app, complex state → Redux Toolkit
Heavy server interaction → React Query + light client state
Atomic/granular updates → Jotai

Quick Start

Zustand (Simplest)

// store/useStore.ts
import { create } from 'zustand'
import { devtools, persist } from 'zustand/middleware'

interface AppState {
  user: User | null
  theme: 'light' | 'dark'
  setUser: (user: User | null) => void
  toggleTheme: () => void
}

export const useStore = create<AppState>()(
  devtools(
    persist(
      (set) => ({
        user: null,
        theme: 'light',
        setUser: (user) => set({ user }),
        toggleTheme: () => set((state) => ({
          theme: state.theme === 'light' ? 'dark' : 'light'
        })),
      }),
      { name: 'app-storage' }
    )
  )
)

// Usage in component
function Header() {
  const { user, theme, toggleTheme } = useStore()
  return (
    <header className={theme}>
      {user?.name}
      <button onClick={toggleTheme}>Toggle Theme</button>
    </header>
  )
}

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.

Best Practices

Do's

  • Colocate state - Keep state as close to where it's used as possible
  • Use selectors - Prevent unnecessary re-renders with selective subscriptions
  • Normalize data - Flatten nested structures for easier updates
  • Type everything - Full TypeScript coverage prevents runtime errors
  • Separate concerns - Server state (React Query) vs client state (Zustand)

Don'ts

  • Don't over-globalize - Not everything needs to be in global state
  • Don't duplicate server state - Let React Query manage it
  • Don't mutate directly - Always use immutable updates
  • Don't store derived data - Compute it instead
  • Don't mix paradigms - Pick one primary solution per category

Migration Guides

From Legacy Redux to RTK

// Before (legacy Redux)
const ADD_TODO = "ADD_TODO";
const addTodo = (text) => ({ type: ADD_TODO, payload: text });
function todosReducer(state = [], action) {
  switch (action.type) {
    case ADD_TODO:
      return [...state, { text: action.payload, completed: false }];
    default:
      return state;
  }
}

// After (Redux Toolkit)
const todosSlice = createSlice({
  name: "todos",
  initialState: [],
  reducers: {
    addTodo: (state, action: PayloadAction<string>) => {
      // Immer allows "mutations"
      state.push({ text: action.payload, completed: false });
    },
  },
});

Signals

GitHub stars
40k
Forks
4k
Last commit
Sep 2026

Questions

What state management libraries does this skill cover?
It covers Redux Toolkit, Zustand, Jotai, and React Query.
When should I use this skill?
Use it when setting up global state, managing server state, or choosing between state management solutions.
Can it help me choose between state management solutions?
Yes, it is used when choosing between state management solutions and can compare Redux Toolkit, Zustand, Jotai, and React Query.
Does it support server state management?
Yes, it covers React Query for managing server state.
Is it limited to a specific React version?
The skill does not state any React version requirements.
Advanced
Item type
skill
Key
react-state-management-wshobson
Source
github.com/wshobson/agents