How Throughline works
Learn how Throughline validates, compiles, and renders traces.
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.
Throughline has two independent layers: a React-free compiler and an optional React 19 player. The root package can compile traces without a browser, account, backend, or network connection.
Compilation
The compile(source) convenience function runs this process. Use compileAst(block) when your Markdown parser has already extracted a code block.
- Parse: a
thlheader chooses one of five domains. Theflowparser reads declarations and steps; the other domains build Programs from their smaller input languages. - Validate: identifiers, links, paths, JSON values, event conflicts, schema versions, and resource limits are checked. Invalid inputs throw
ProgramErrorwith diagnostics. - Compile: the initial values form frame zero. Each named step applies its events and creates another complete snapshot.
A step is atomic: its events produce one frame, not intermediate frames. A send event describes movement along a link; only set updates values. Hidden entities retain values in trace data.
See Core concepts for frame semantics and Errors and limits for constraints.
Rendering and playback
The optional player uses existing frames to create a scene of visible entities, groups, and links. It measures available width in the browser and adapts its SVG layout. Captions and an inspector expose the state as text, not only through visuals.
Seeking selects a frame by index. It does not rerun parsing, compilation, or arbitrary authored code. When the trace prop changes identity, playback resets to the first frame.
For component behavior see React player; for appearance see Styling.
Responsibilities of the host application
Throughline compiles bounded state descriptions; it is not a JavaScript sandbox or an authorization system. An application accepting user input is responsible for authentication, rate limiting, content moderation where appropriate, error boundaries, and persistence. Do not render user-supplied labels or notes as raw HTML.
The package limits source size and compilation work, but those limits are not guarantees of exact CPU time or memory usage. Validate content during publication when possible.