react-state-machines

Installation
SKILL.md

React State Machines with XState v5

Overview

State machines make impossible states unrepresentable by modeling UI behavior as explicit states, transitions, and events. XState v5 (2.5M+ weekly npm downloads) unifies state machines with the actor model—every machine is an independent entity with its own lifecycle, enabling sophisticated composition patterns.

When to Use This Skill

Trigger patterns:

  • Boolean flag explosion: multiple isLoading, isError, isSuccess flags
  • Implicit states: writing if (isLoading && !isError && data) to derive mode
  • Defensive coding: guards before state updates to prevent invalid transitions
  • Timing coordination: timeouts, delays, debouncing across states
  • State dependencies: one state depends on another to update correctly

Do not use for:

  • Simple boolean toggles with no async (useState is simpler)
  • Single form fields with basic validation (useReducer suffices)
  • Server state caching (React Query/TanStack Query handles this)
Related skills
Installs
156
GitHub Stars
44
First Seen
Jan 23, 2026