Managing State Machines

How to add, remove, and read state machines in a .lottie package with dotlottie-io.

Managing State Machines

State machines define interactive behavior for a Lottie animation — states, transitions, and actions that a player uses to control playback in response to input or other events.

For the full structure and semantics of a state machine's JSON, see the official state machine documentation on dotlottie.io.

Adding a state machine

dotlottie.addStateMachine("sm-button", "Button Interaction Logic", JSON.stringify(stateMachineJson));
  • id — a unique identifier for this state machine within the package

  • name — an optional human-readable display name; pass null to omit it

  • jsonData — the state machine definition as a Buffer or JSON string

Removing and reading state machines

dotlottie.removeStateMachine("sm-button"); // throws if not found
dotlottie.getStateMachineJson("sm-button"); // → string | null
dotlottie.stateMachineIds(); // → string[]

Finding which animations a state machine controls

dotlottie.animationsUsedByStateMachine("sm-button"); // → string[]

This returns every unique animation ID referenced by a PlaybackState entry inside the state machine's definition.

Next up: The Manifest

Last updated: August 5, 2026 at 11:47 AMEdit this page