This page is the shortest path from "I think I want the TUI/protocol surface" to a runnable local example.
Use it when you do not want to reverse-engineer the worker, snapshot-store, and terminal render loop from the larger guides.
- starting the Node worker with
stream-mdx/worker/node - applying
PATCHmessages to the@stream-mdx/tuisnapshot store - rendering
Block[]back to the terminal - a conservative baseline for terminal consumers before you add Ink, blessed, or custom ANSI layout
From the repo root:
npm install
npm run build:packages
npm run example:tui-minimalIf you prefer to run the file directly:
node examples/tui-minimal/index.mjs- render arbitrary MDX components in a terminal
- ship built-in ANSI syntax highlighting
- preserve terminal scrollback
- provide a full reference TUI framework
That is deliberate. StreamMDX owns parsing, patches, and block materialization. Your terminal application owns final presentation.
streaming markdown
|
v
Node worker helper (`stream-mdx/worker/node`)
|
v
PATCH messages
|
v
snapshot store (`@stream-mdx/tui`)
|
v
terminal renderer
import { createWorkerThread } from "stream-mdx/worker/node";
import { createSnapshotStore } from "@stream-mdx/tui";
import type { WorkerOut } from "stream-mdx/core";
const worker = createWorkerThread({ stdout: true, stderr: true });
const store = createSnapshotStore();
worker.on("message", (msg: WorkerOut) => {
if (msg.type !== "PATCH") return;
store.applyPatches(msg.patches);
renderToTerminal(store.getBlocks());
});
worker.postMessage({
type: "INIT",
initialContent: "",
docPlugins: { tables: true, html: true, mdx: true, math: true, footnotes: true },
mdx: { compileMode: "worker" },
});
worker.postMessage({ type: "APPEND", text: "# Hello\n\nStreaming **markdown** in a TUI.\n" });
worker.postMessage({ type: "FINALIZE" });Once this loop works locally, use the next docs in this order:
TUI_GUIDE.mdfor the recommended runtime and store choicesCLI_USAGE.mdfor lower-level Node runtime detailsSTREAMMDX_JSON_DIFF_SPEC.mdif you actually need a transport boundary