Skip to main content
A completed match can be captured as a self-contained JSON envelope that any machine with the game definition can replay. This is the foundation for spectator views, analysis tools, and inspector.

Capture from a local session

The session argument can be an actual LocalGameSession or any object that exposes getReplayData(). React’s useMatch().state.replayData exposes it in local mode; pass { getReplayData: () => replayData } if you want to capture from a component.

Envelope shape

Everything is JSON. You can store the envelope anywhere strings go.

Load and materialize

materializeSavedReplay replays the action log against a fresh reducer and returns a ReplayTimeline<TGame>:
Each frame has the full snapshot at that point, the transition that produced it, and an optional player view.

Scrub with a cursor

The cursor drives scrub-style replay UIs. Every mutating method returns the new ReplayCursorState so you can feed it into React state yourself.

Branching

For “what if” analysis, fork the timeline at an action and replay new actions from there:
Branches share the prefix up to the fork point but diverge after. Devtools uses this to let you try different moves from a captured state.

Load in inspector

For an interactive inspector, wrap the timeline with the ReplayInspector from @openturn/inspector-ui’s createInspector(bindings). See how-to: debug with inspector.