A small, hook-based state-management library for React with no providers required.
- Stars
- 30,422
- Forks
- 1,413
- Open issues
- 123
- Last commit
- 8 hours ago
What is it?
XState is a state management and orchestration library for JavaScript and TypeScript, usable in both frontend and backend code. It models application logic as state machines, statecharts, and actors, so transitions, side effects, and allowed events are declared explicitly rather than scattered across conditionals.
The core package, xstate, provides machine definitions, actors that run machine logic and expose snapshots to subscribers, and support for hierarchical, parallel, and history states. Stately Studio, a visual editor, can be used to design machines and export them to XState v5. Companion packages add bindings for React, Vue, Svelte, and Solid.
For simpler cases, the separate @xstate/store package offers a small event-based store with reactive atoms and strong TypeScript inference, and it works with or without the core library.
Key features
- 01Define state machines and statecharts with hierarchical, parallel, and history states.
- 02Run logic as actors that expose state snapshots to subscribers.
- 03Zero runtime dependencies.
- 04Visual design and export through Stately Studio.
- 05Framework bindings for React, Vue, Svelte, and Solid.
- 06Separate lightweight @xstate/store for event-based state management.
Use cases
- Managing multi-step UI flows such as forms, wizards, or checkout processes.
- Orchestrating long-running backend workflows and background jobs.
- Making complex component state transitions explicit and testable.
- Using a small event-driven store as an alternative to Redux or Zustand.
Quick start
- 1
Install the xstate package with npm
npm install xstate
In collections
Topics
FAQ
- What is xstate?
- A zero-dependency JavaScript/TypeScript library for state machines, statecharts, and actors to manage complex app and workflow logic. XState is a state management and orchestration library for JavaScript and TypeScript, usable in both frontend and backend code. It models application logic as state machines, statecharts, and actors, so transitions, side effects, and allowed events are declared explicitly rather than scattered across conditionals.
- Is xstate free to use? What license does it have?
- xstate is open source under the MIT license. Check the license terms before using it in commercial products.
- Is xstate still maintained?
- Actively maintained. The last commit to xstate was on Nov 7, 2026.
- What can I use xstate for?
- Managing multi-step UI flows such as forms, wizards, or checkout processes. Orchestrating long-running backend workflows and background jobs. Making complex component state transitions explicit and testable. Using a small event-driven store as an alternative to Redux or Zustand.
- How do I install xstate?
- Install the xstate package with npm: npm install xstate
- Where can I get xstate?
- The source code and installation instructions are on GitHub: https://github.com/statelyai/xstate
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A JavaScript library for predictable, maintainable global state management, usable with React or any other view library.
Simple, scalable state management for JavaScript and TypeScript apps, with automatic dependency tracking and optimal re-rendering.
Official React bindings for Redux, connecting Redux stores to React components via hooks and a Provider.
An evidence-gated engineering workflow that enforces the five SPARC phases (Specification, Pseudocode, Architecture, Refinement, Completion) through a TypeScript state machine, CLI, and MCP server.
A Python library for building decision-making applications like chatbots and agents as state machines, with a built-in UI for tracing and monitoring.