Stately

Stately & XState docs

Learn XState, state machines, statecharts, and actors. Find tutorials, API guides, and documentation for the Stately visual editor.

Welcome to the Stately and XState docs

Stately.ai is a visual software modeling platform for modeling your app & business logic as state machines/statecharts and actors, and scales to any level of complexity.

XState is an open source library for modeling and running application logic in JavaScript and TypeScript.

XState v6 is in beta. Its APIs and behavior may change before the stable release. Read the v6 beta docs or the stable v5 docs.

Quick start

Install XState:

npm install xstate@beta

Create a state machine:

import { createMachine, createActor } from 'xstate';

const toggleMachine = createMachine({
  id: 'toggle',
  initial: 'inactive',
  states: {
    inactive: { on: { toggle: { target: 'active' } } },
    active: { on: { toggle: { target: 'inactive' } } },
  },
});

const toggleActor = createActor(toggleMachine);
toggleActor.start();

toggleActor.send({ type: 'toggle' });
console.log(toggleActor.getSnapshot().value); // 'active'

toggleActor.send({ type: 'toggle' });
console.log(toggleActor.getSnapshot().value); // 'inactive'

Read the v6 beta quick start guide to learn more.

Loading machine preview…

Stately Studio or XState?

Stately Studio and XState are designed to be used together. Use Stately Studio's visual editor to collaboratively model your app logic and use XState to integrate that logic into your codebase.

You can also use XState in your codebase without Stately Studio, and you're welcome to use Stately Studio if you're not yet familiar with XState.

Who is Stately?

The Stately team including Gavin, Farzad, David, Mateusz, Jenny, Laura, Anders, Nick, and Kevin, all standing in front of garage doors, laughing and smiling at each other.

We're Stately, a small team founded by David Khourshid, the creator of XState. Stately is building Stately Studio, where you can visualize your application logic and collaborate with your whole team.

On this page