0xBUFF / docs

Getting started

Install Throughline, create your first visualization, and display it in React.

Version scope — v0.0.2 (historical schema 1). This page and its examples use @0xbuff/throughline@0.0.2, the version pinned by this documentation app. They do not describe the unreleased schema-2 API intended for v0.2.0. See compatibility and upgrading.

This guide starts with the standalone compiler. You can add the React player afterward.

Before you begin

Use an ESM project and Node.js 24 or newer for Node-based execution. React is not required to compile traces.

1. Install Throughline

npm install @0xbuff/throughline@0.0.2

Keep this exact version and commit your package lockfile so the examples match the installed API.

2. Compile a trace

Create counter.mjs:

import { compile } from "@0xbuff/throughline";

const source = [
  "thl flow",
  'node counter "Counter" = 0',
  'step "Increment"',
  "  set counter = 1",
  '  note "The counter is now one."',
  'step "Increment again"',
  "  set counter = 2",
].join("\n");

const trace = compile(source);

for (const frame of trace.frames) {
  const counter = frame.state.entities.find((item) => item.id === "counter");
  console.log(frame.index, frame.label, counter?.value);
}

Run the file:

node counter.mjs

Output:

0 Initial state 0
1 Increment 1
2 Increment again 2

Each step creates a frame; frame 0 is the initial state. The compiler validates the source and produces the frames once. Moving between frames does not rerun the source.

Try it interactively

Follow a changing value

Use Play or the step controls to see how the counter changes.

Loading the interactive player…
View trace source
thl flow
node counter "Counter" = 0
step "Increment"
  set counter = 1
  note "The counter is now one."
step "Increment again"
  set counter = 2
  note "The counter is now two."

The code above and this player describe the same sequence of states. Use Next to inspect each change, then open View trace source to compare the input.

3. Display the trace in React (optional)

Install React 19 and React DOM 19 if your project does not already include them:

npm install react@^19 react-dom@^19

Import the player and its CSS. In an application, import the stylesheet once in your root entry.

import { compile } from "@0xbuff/throughline";
import { ThroughlinePlayer } from "@0xbuff/throughline/react";
import "@0xbuff/throughline/styles/throughline.css";

const trace = compile(
  'thl flow\nnode counter "Counter" = 0\nstep "Increment"\nset counter = 1',
);

export function CounterExample() {
  return <ThroughlinePlayer trace={trace} />;
}

The player starts paused at frame zero and includes stepping controls, captions, and an inspector. Keep the trace object stable between renders; replacing it resets playback.

See React player for props, keyboard controls, and optional sound.

Next steps

The compiler accepts one thl block at a time, either with a bare header or its Markdown fence. If your content is a full Markdown article, extract each thl code block before compiling it.

On this page