---
matra:
entry: main.matra
values:
- content.js.part
---
# Compose a page with Matra packages
```main.matra
html(lang="en") {
head {
title { content.pageTitle(content.title) }
}
body {
header {
p { "MATRA / PACKAGE EXAMPLES" }
h1 { content.title }
p { content.description }
}
main {
...for (item in content.packages) {
section(id=item.id) {
h2 { item.name }
p { item.description }
pre { code { item.example } }
}
}
}
footer {
p { "These package workflows are experimental; check each package's release notes." }
}
}
}
```
```content.js.part
({
title: "Compose a page with Matra packages",
description: "Use the CLI to start a project, Core to evaluate Matra documents, and site-generation to build a site.",
pageTitle: title => `${title} | Matra`,
packages: [
{
id: "cli",
name: "@matra/cli",
description: "Create and preview a starter project with the experimental CLI.",
example: "npm install --global @matra/[email protected]\nmatra init hello\ncd hello && matra dev"
},
{
id: "core",
name: "@matra/core",
description: "Build and run a literate Matra document in Node.js.",
example: 'const value = await runLiterate(await buildLiterate(source))'
},
{
id: "site-generation",
name: "@matra/site-generation",
description: "Generate pages from Matra templates, page data, and a shared layout.",
example: 'await generateSite({ root, output: "dist", pages })'
}
]
})
```MATRA / EXPERIMENTAL STRUCTURAL LANGUAGE
Build documents with code.
Matra is an experimental structural language aiming to handle documents, data, and programs through a shared structure. In v0.3, you can describe document structure, connect JavaScript values, and generate HTML from a document AST. If you came here from the technical book at TechBookFest, start with the CLI, compare source with output, then explore the specifications and implementation.
Core v0.3.0 / HTML v0.3.0, experimental releases for Node.js.
Experimental CLI. Requires Node.js 22/24 and npm.
npm install --global @matra/[email protected]SOURCE → DOCUMENT AST → HTML
Compare source with generated output
This site is itself generated with Matra. Below are the build-executed source and actual HTML output. A named Markdown code fence selects the entry, the document is evaluated with JavaScript values, and its document AST is passed to the HTML renderer.
The left panel shows the complete Markdown source. matra.entry selects main.matra, and matra.values exposes the JavaScript expression as content. @matra/core evaluates the document, while @matra/site-generation builds a site from pages, shared layouts, and data. The CLI creates and builds starter projects. The code below shows each package in use.
<html lang="en">
<head>
<title>Compose a page with Matra packages | Matra</title>
</head>
<body>
<header>
<p>MATRA / PACKAGE EXAMPLES</p>
<h1>Compose a page with Matra packages</h1>
<p>Use the CLI to start a project, Core to evaluate Matra documents, and site-generation to build a site.</p>
</header>
<main>
<section id="cli">
<h2>@matra/cli</h2>
<p>Create and preview a starter project with the experimental CLI.</p>
<pre><code>npm install --global @matra/[email protected]
matra init hello
cd hello && matra dev</code></pre>
</section>
<section id="core">
<h2>@matra/core</h2>
<p>Build and run a literate Matra document in Node.js.</p>
<pre><code>const value = await runLiterate(await buildLiterate(source))</code></pre>
</section>
<section id="site-generation">
<h2>@matra/site-generation</h2>
<p>Generate pages from Matra templates, page data, and a shared layout.</p>
<pre><code>await generateSite({ root, output: "dist", pages })</code></pre>
</section>
</main>
<footer>
<p>These package workflows are experimental; check each package's release notes.</p>
</footer>
</body>
</html>Beyond the technical book
Run it. Read the model. Trace the implementation.
01 / RUN
Create your first page with the CLI
Use Node.js 22/24 and npm to install a pinned CLI version, then go from matra init to a build and local preview.
Get Started →Runnable examples and SVG/MathML demos →02 / MODEL
Data Model → AST → Grammar
Start with tag, props, children, and MatraJSON, then examine document value representation, source syntax, and the boundary between parsing and evaluation.
Start with the data model →Parsing and evaluation →03 / IMPLEMENTATION
Explore the public APIs and source
Understand the responsibilities of Core evaluation, AST conversion, and the HTML renderer before integrating JavaScript or building your own tools.
Packages and source →Language design and technical background →Project status
Implemented paths and experimental contracts.
The CLI and Node.js literate API are experimental. Builds execute document JavaScript, so use trusted source only. The Playground is HTML-only; SVG/MathML are focused Core/HTML demos. These do not provide dedicated Graphics/Math APIs or a general-purpose sandbox.