typstream

Compatibility

The Typst version typstream compiles with, the browsers, frameworks and Node.js versions it runs on, module formats, bundle sizes, fonts and Typst packages.

Typst 0.15.1

typstream compiles with Typst 0.15.1, and only that version. The engine (Typst compiled to WebAssembly), the healer's parser (a port of Typst 0.15.1's lexer and parser, checked against Typst's own) and the server package are pinned to it together. Upgrading Typst is a deliberate release, not something a dependency update does.

For your documents, that means:

  • Typst 0.15 syntax and standard library. Functions and parameters added in later Typst versions don't exist yet. Tell the model which version it writes for; the prompts in these docs say "Typst 0.15 markup".
  • The paged target (SVG pages, PDF) is Typst's own layout, the same as typst compile 0.15.1 produces.
  • The HTML target is Typst 0.15.1's HTML export, which Typst still develops. It writes semantic HTML and MathML, but drops layout it can't express (grids, alignment, boxes, shapes); html-compat brings most of it back. Page settings (headers, footers, page numbers, margins) have no HTML equivalent and stay missing. See Render targets.
  • Typst packages come from an allowlist of pinned versions (below). A document that imports another version of an allowed package gets the nearest allowed one, with a warning.

Browsers

The browser tests run in Chromium, Firefox and WebKit (Playwright 1.64), for the engine worker, the renderers, the React bindings, and a page under a strict Content-Security-Policy. typstream needs:

FeatureUsed forWithout it
WebAssemblyThe Typst engineNothing renders. Under a CSP, allow 'wasm-unsafe-eval' in script-src.
Module workersThe engine runs in new Worker(url, { type: "module" })Nothing renders.
Constructed stylesheetsAdding the renderers' CSS without inline stylesA <style> element instead, which a strict CSP refuses without 'unsafe-inline' (Safari before 16.4).
MathMLMath in the HTML targetMath doesn't render in the HTML target. The paged target draws math itself.
IntersectionObserverOpening documents only near the viewportDocuments open right away.
ResizeObserverThe paged fit-width and reflow layouts
Cache StorageKeeping fonts and package tarballs across sessionsThey come from the HTTP cache.

Cross-origin isolation (COOP/COEP) and SharedArrayBuffer are not needed. Trusted Types (require-trusted-types-for 'script') work with trusted-types typstream in the policy. The CSP that works is in Security.

Frameworks and runtimes

SupportedTested with
React19 (react ^19.0.0 is a peer dependency of typstream and @typstream/react)19.3
Next.jsApp Router; the React bundles are marked "use client"16.4, Turbopack (webpack needs no configuration either)
ViteNo configuration8.3
Vercel AI SDK<Typstream> takes the text so far from any source; the example uses useChatai 7, @ai-sdk/react 4
Node.js (@typstream/node)20 or later24

Without React, @typstream/dom works in any framework or none: see Without a framework. On the server, <Typstream> renders an empty <div> and starts in the browser.

Module format

Every package is ESM only, with TypeScript types included. There is no CommonJS build: use import, not require(). Offsets in every API (diagnostics, edits, heal's source map) are UTF-16 indices, the way JavaScript strings index.

Bundle sizes

Budgets in minified and gzipped ESM. Each is checked on every change, so they are upper bounds, not estimates.

PartBudgetNotes
@typstream/heal≤ 16.4 KBWith @typstream/core's helpers inlined.
@typstream/engine, main thread≤ 10.2 KBWithout heal.
@typstream/engine/websocket≤ 1.5 KBfromWebSocket, only for apps that compile on a server.
@typstream/engine/images≤ 1.5 KBfetchImages, only for apps that show images from the web.
@typstream/engine/prefetch≤ 3 KBprefetchEngine, downloading the engine's files early; mostly engine-wasm's font list, which typstream already has. @typstream/react loads it only for level: "fetch".
@typstream/react, with @typstream/dom≤ 35.6 KBWithout React and the engine.
@typstream/dom HTML renderer≤ 23.3 KBIncluding its CSS, and the layout of the HTML target on pages.
@typstream/dom paged renderer≤ 7.2 KB
@typstream/dom standalone HTML export≤ 2 KB
@typstream/ai≤ 4.5 KBWithout heal and core.
Engine worker JS≤ 40 KBLoaded in the worker, not your bundle. Without the wasm and fonts.
@typstream/docx≤ 14.4 KBLoaded by the worker on the first DOCX export.
Typst wasm (@typstream/engine-wasm)≤ 6.32 MB brotliAbout 21 MB uncompressed; HTML, SVG, PDF and the DOCX export's model in one build.
@typstream/mindmap plugin≤ 10 KBIts React entry ≤ 1 KB; React Flow ≤ 66 KB, loaded when the first map shows.
@typstream/mermaid plugin≤ 6 KBIts generator, loaded by the worker when a document with the plugin opens: ≤ 285 KB, pele included.

In practice, typstream adds about 90 KB gzipped to a React app's main bundle (React itself excluded): the bindings, renderers, engine client and healer, plus html-compat's prelude and CSS and the package list. Plugins you add, such as edu, come on top. The wasm, the fonts and the packages are separate files, fetched by the worker when it starts or when a document needs them: see what gets downloaded, and when.

Fonts

FontsScriptsLoaded
Libertinus Serif (regular, bold, italic)Latin, Greek, Cyrillic, HebrewWhen the engine starts (3.7 MB with the two below, 1.4 MB brotli)
New Computer Modern MathMathWhen the engine starts; also registered as a web font for MathML
DejaVu Sans MonoCodeWhen the engine starts
Noto Naskh Arabic (regular, bold)ArabicThe first time a document needs it (47–79 KB brotli per face)
Noto Serif Bengali (regular, bold)BengaliThe first time a document needs it
Noto Serif Devanagari (regular, bold)DevanagariThe first time a document needs it

These are the fonts the engine draws with: in the paged target, PDF exports, and drawings inside HTML. In the HTML target the browser draws the text, with your page's fonts.

CJK fonts are not included: a single weight of Noto Serif SC is 11.6 MB. Add the fonts you need through a plugin on createEngine; see Fonts and languages. @typstream/node loads Typst's bundled fonts and the script fonts up front, and takes more with fontPaths or fonts.

Typst packages

Documents can import these Typst Universe packages by default. They are vendored with integrity hashes and served from your own origin, fetched only when a document imports one:

ForPackage
Diagrams@preview/cetz:0.5.3, @preview/fletcher:0.5.8
Math@preview/cetz-plot:0.1.4, @preview/physica:0.9.8, @preview/unify:0.8.1
Chemistry@preview/chemformula:0.1.3, @preview/alchemist:0.2.0

fletcher diagrams render in the paged target only; in the HTML target they stay empty for now. Other packages aren't fetched unless you add them to the allowlist. Details in @typstream/universe and Typst packages.

On this page