XState models application and workflow logic with state machines, statecharts, and the actor model for JavaScript and TypeScript. The core package ships with no runtime dependencies.
Overview
XState targets complex, event-driven logic in front-end and back-end JavaScript or TypeScript code. Developers describe behavior as states, events, transitions, nested and parallel regions, history states, and coordinated actors so flows stay explicit and testable.
The main xstate package implements finite state machines and statecharts with an interpreter, plus utilities for graph traversal and model-based testing. Related packages add React, Vue, Svelte, and Solid bindings, a lightweight @xstate/store for simpler event stores, Effect integration, and a minimal xstate/fsm module for flat machines.
Design draws on the SCXML specification. Teams can author machines in code or use Stately Studio to edit visuals, export XState definitions, generate tests and docs, and collaborate; Studio is optional for using the library alone.
Documentation and examples cover hierarchical, parallel, and history states, migration guides, and templates for plain TypeScript or framework stacks. Experimental APIs can simulate pure actor systems with immutable snapshots and external effects returned as data.
Key features
- State machines and statecharts interpreter
- Actor model for orchestration
- Zero runtime dependency core package
- Framework bindings for major UI libraries
- Lightweight @xstate/store option
- Graph traversal and model-based testing
- Visual authoring via Stately Studio
- SCXML-inspired formalism
Use cases
- Multi-step UI workflows
- Backend workflow orchestration
- Replacing ad hoc boolean flags
- Modeling parallel application regions
- Background job and process logic