Stately
XState v6 alpha

Inspection

Observe actor systems and transitions.

XState v6 is in alpha

APIs and behavior may change before the stable release.

Pass an inspector to the root actor with the inspect option.

const actor = createActor(machine, {
  inspect: (inspectionEvent) => {
    console.log(inspectionEvent.type, inspectionEvent);
  }
});

Inspection emits two event types:

TypeContains
@xstate.actorActor identity and parent information.
@xstate.transitionThe event, snapshot, source, target and microsteps.

Use inspection for developer tools, logs and visualizers. Do not change application state from an inspector.

Inspection can power a statechart visualizer or attach actor and transition details to a failed request trace.

Inspection cheatsheet

createActor(logic, { inspect });
createActor(logic, { inspect: (event) => console.log(event) });

On this page