0xBUFF / docs

Framework and runtime support

Use Throughline with React, Next.js, React Router, Astro, Node.js, and other runtimes.

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.

The compiler is a standalone ESM package. The official visual player requires React 19 and its separately imported CSS.

Choose your environment

EnvironmentCompilerOfficial player
Node.js 24+ ESM script or buildYesNo interactive browser UI
React 19 with Vite or React RouterYesYes
Next.js App Router with React 19YesYes, in a client component
Astro with React integrationYesYes, in a hydrated React island
Markdown/MDX siteYes, after extracting thl fencesYes, when the host connects a React component
Vue, Svelte, or vanilla JSTrace data can be consumedNo official non-React player

Throughline v0.0.2 does not ship framework-specific adapters, a Web Component, or an SVG file exporter.

React and Vite

Follow the Getting started example. Import the package CSS once in your app entry, compile the source, and render <ThroughlinePlayer trace={trace} />.

Memoize traces computed from props with useMemo; a new trace object resets player position.

Next.js App Router

Put the player inside a client component:

// app/components/TracePlayer.tsx
"use client";

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

export function TracePlayer({ source }: { source: string }) {
  const trace = useMemo(() => compile(source), [source]);
  return <ThroughlinePlayer trace={trace} />;
}

Import @0xbuff/throughline/styles/throughline.css globally in app/layout.tsx. A server component can pass plain source text or serializable trace data to the client component. Validate author-controlled content before publishing it.

Astro

Enable Astro's React integration and hydrate the player:

---
import TraceIsland from "../components/TraceIsland";
const source = "thl binary\na = 1011\nb = 0110";
---

<TraceIsland source={source} client:load />

TraceIsland is a React component with the same compilation and player imports used in the Next.js example, without the "use client" directive. Import the published CSS in the component or a shared stylesheet. Without a hydration directive, the player cannot respond to browser input.

Markdown, MDX, and Fumadocs

A regular Markdown renderer displays thl fences as code. To render a player, the host must extract the fence, compile it, and mount a React component.

Fumadocs users can register a custom MDX component and validate thl blocks during the content build. See Markdown and MDX integration for the implementation.

Node.js and non-React applications

The compiler can run in a Node ESM build script without React:

import { writeFile } from "node:fs/promises";
import { compile, describeFrame } from "@0xbuff/throughline";

const trace = compile("thl callstack\nfact 3");
await writeFile("trace.json", JSON.stringify(trace, null, 2));
await writeFile(
  "trace.txt",
  trace.frames.map((frame) => describeFrame(frame, trace.frames.length)).join("\n"),
);

In Vue, Svelte, or another renderer, read trace.frames and supply your own layout, controls, and accessibility. Throughline's official SVG scene is part of the React player, not a framework-neutral export.

For worker-style runtimes or other hosts not listed above, test the compiler and resource limits in the target environment; v0.0.2 does not guarantee every ESM runtime.

See Integration options for build-time versus runtime compilation and Compatibility for supported versions.

On this page