Skip to content

Getting Started with Typst

The Typst backend compiles Typst markup into a PDF. Typst is a modern typesetting system — think LaTeX’s power with a far friendlier syntax — which makes it a natural fit for invoices, contracts, certificates, and other polished documents.

Unlike the JavaScript backends, Typst is not run in the browser or the isolated-vm sandbox. It shells out to the native typst binary on the server, so a Typst script always runs in remote mode. There is no client-side preview path: hit ▶ Run and the compile happens on the backend, returning the finished PDF to the viewer pane.

Create a new project with Typst as the backend and Run the starter file. The markup itself needs no boilerplate:

#set page(paper: "a4", margin: 2cm)
#set text(size: 11pt)
= Hello, Typst!
This paragraph is *typeset* by the Typst compiler and rendered as a PDF.
- Bullet lists use a leading dash.
- _Emphasis_ and *strong* wrap text in underscores / asterisks.

A line starting with = is a heading; == is a sub-heading. Prose is written directly. A # switches into code mode for a single expression, and #{ … } or #[ … ] for a block. That is the whole mental model: markup by default, # to compute.

Parameters are declared in frontmatter, not JavaScript

Section titled “Parameters are declared in frontmatter, not JavaScript”

Typst has no getParameterDefinitions() — that is a JavaScript concept and Typst is not JavaScript. Instead, parameters are declared in a YAML frontmatter block at the very top of the file, wrapped in a Typst block comment so the file stays valid Typst even if the block is ignored:

/*javasculpt-params
- name: title
type: text
default: "Quarterly Report"
- name: copies
type: number
default: 1
min: 1
max: 20
*/
#set page(paper: "a4")
= #sys.inputs.title
Print run: #sys.inputs.copies copies.

Each entry becomes a live control in the editor, exactly like a JS param would. The values are delivered to the compile as sys.inputs.<name>. Note that every input arrives as a string (they are passed on the command line), so a number param read via sys.inputs.copies is the text "1", not the integer 1. See the Parameters and inputs tutorial for the full type list and the one-level nesting rules.

The frontmatter block is optional — a plain, non-parametric .typ file with no block simply has no declared parameters and runs unchanged.

Beyond loose parameters, fabricadabra can drive a Typst script from a structured data payload — this is how the Orders and Clients features generate invoices, receipts, and contracts from your live records. That JSON is read with:

#let data = json(bytes(sys.inputs.data))

The Generating documents tutorial covers the exact data shape and how to develop against realistic sample data without a live order.

The compile always produces a single PDF, shown in the viewer and downloadable with ↓ Download. Compile errors are surfaced inline with the offending file, line, and column.

  • Parameters and inputs — the full frontmatter param reference.
  • Generating documents — drive a template from the Orders/Clients data shape.
  • Browse the Invoice, Contract, Certificate, and Letterhead examples for complete, working starting points.
  • The Typst documentation is the reference for the markup language itself.