Skip to content
Version: XState v5

Systems

An actor system is a collection of actors that can communicate with each other. Actors can invoke/spawn other actors, which forms a natural hierarchy of actors that belong to the same system.

In XState, a system is implicitly created from the root actor, which is the actor that is returned from interpret(machine).start(). The system can be accessed from the actor.system property of actors, and from the destructured { system } property from state machine actions:

import { createMachine, interpret } from 'xstate';

const machine = createMachine({
entry: ({ system }) => {
// ...
},
});

const actor = interpret(machine).start();
actor.system;

The root of a system can also be explicitly assigned a systemId in the interpret(...) function:

import { interpret } from 'xstate';

const actor = interpret(machine, {
systemId: 'root-id'
});

actor.start();

This is useful for actors in the system to be able send events to the root actor.