statelyai/xstate

State machines, statecharts, and actors for complex logic

29,372 stars TypeScript 10 components 6 connections

TypeScript state machines, statecharts, and actor model library with framework integrations

Events flow through state machines to produce new states, or through stores to update context. Framework integrations subscribe to these updates and trigger UI re-renders.

Under the hood, the system uses 3 feedback loops, 3 data pools, 2 control points to manage its runtime behavior.

Structural Verdict

A 10-component data pipeline with 6 connections. 423 files analyzed. Loosely coupled — components are relatively independent.

How Data Flows Through the System

Events flow through state machines to produce new states, or through stores to update context. Framework integrations subscribe to these updates and trigger UI re-renders.

  1. Event dispatch — Components send events to actors or stores via send() or store.send()
  2. State transition — Core engine processes events through state machine logic or store reducers
  3. State update — New state is computed and stored, observers are notified
  4. UI reaction — Framework hooks receive updates and trigger component re-renders
  5. Devtools inspection — Development tools receive state changes for debugging visualization

System Behavior

How the system actually operates at runtime — where data accumulates, what loops, what waits, and what controls what.

Data Pools

Actor Registry (in-memory)
Global registry of active actors for development tools
Store State (state-store)
Current context and computed state in store instances
WebSocket Connections (queue)
Connected debugging clients for state inspection

Feedback Loops

Delays & Async Processing

Control Points

Package Structure

This monorepo contains 14 packages:

xstate (library)
Core state machine and actor system engine, framework-agnostic with TypeScript definitions
xstate-react (library)
React hooks and utilities for XState integration
xstate-vue (library)
Vue composition API integration for XState
xstate-solid (library)
SolidJS reactive primitives for XState
xstate-svelte (library)
Svelte store integration for XState
xstate-store (library)
Simplified reactive state management without state machines
xstate-store-react (library)
React hooks for XState store
xstate-store-angular (library)
Angular signals integration for XState store
xstate-store-preact (library)
Preact hooks for XState store with custom useSyncExternalStore
xstate-store-solid (library)
SolidJS signals for XState store
xstate-store-svelte (library)
Svelte integration for XState store
xstate-store-vue (library)
Vue composition API for XState store
xstate-immer (library)
Immer integration for immutable XState context updates
xstate-inspect (tooling)
Browser and WebSocket-based debugging tools for XState

Technology Stack

TypeScript (language)
Primary language with comprehensive type definitions
Vitest (testing)
Testing framework
Preconstruct (build)
Package build system for monorepo
pnpm (build)
Package manager with workspace support
ESLint (build)
Code linting
Changesets (build)
Version management and release automation
Immer (library)
Immutable state updates
WebSocket (infra)
Real-time debugging communication

Key Components

Configuration

pnpm-workspace.yaml (yaml)

Explore the interactive analysis

See the full architecture map, data flow, and code patterns visualization.

Analyze on CodeSea

Related Data Pipeline Repositories

Frequently Asked Questions

What is xstate used for?

TypeScript state machines, statecharts, and actor model library with framework integrations statelyai/xstate is a 10-component data pipeline written in TypeScript. Loosely coupled — components are relatively independent. The codebase contains 423 files.

How is xstate architected?

xstate is organized into 4 architecture layers: Core State Machine Engine, Framework Integrations, Store Abstraction, Development Tools. Loosely coupled — components are relatively independent. This layered structure keeps concerns separated and modules independent.

How does data flow through xstate?

Data moves through 5 stages: Event dispatch → State transition → State update → UI reaction → Devtools inspection. Events flow through state machines to produce new states, or through stores to update context. Framework integrations subscribe to these updates and trigger UI re-renders. This pipeline design reflects a complex multi-stage processing system.

What technologies does xstate use?

The core stack includes TypeScript (Primary language with comprehensive type definitions), Vitest (Testing framework), Preconstruct (Package build system for monorepo), pnpm (Package manager with workspace support), ESLint (Code linting), Changesets (Version management and release automation), and 2 more. A focused set of dependencies that keeps the build manageable.

What system dynamics does xstate have?

xstate exhibits 3 data pools (Actor Registry, Store State), 3 feedback loops, 2 control points, 2 delays. The feedback loops handle recursive and convergence. These runtime behaviors shape how the system responds to load, failures, and configuration changes.

What design patterns does xstate use?

5 design patterns detected: Actor Model, Framework Adapter Pattern, Store Pattern, Development Integration, Immutable Updates.

Analyzed on April 1, 2026 by CodeSea. Written by .