Skip to content
Version: XState v4


You can install XState using your favorite package manager or embed the <script> directly from a CDN.

Installation Snippets

using yarn
yarn add xstate
using npm
npm install xstate


You can embed XState from the unpkg CDN:

<script src=""></script>

The variable XState will be available globally, which will give you access to the top-level exports.

const { createMachine, actions, interpret } = XState; // global variable: window.XState

const lightMachine = createMachine({
// ...

const lightActor = interpret(lightMachine);