DOCUMENTATION

Run the CLI. Integrate the APIs.

Test the structures you read about in the technical book on your own machine. Create a page with the CLI, then explore examples using Core, site-generation, and HTML alongside grammar and evaluation contracts.

Supported setup: Node.js 22/24. The literate API is experimental and Node.js-only.

Get Started: create a page with npm

An experimental release for Windows and macOS using Node.js 22/24 and npm.

1. Install Node.js

Install Node.js 22 or 24 and npm on Windows or macOS, then open a terminal. The same commands work in PowerShell.

node --version
npm --version
Official Node.js download

2. Install the CLI

Install the experimental version with this pinned command. If PowerShell blocks scripts, use npm.cmd and matra.cmd instead. If the global command is not found, check npm's prefix and PATH.

npm install --global @matra/[email protected]
matra --version
About npm prefix

3. Create a page

Choose a directory that does not exist for hello. Open dist/index.html or preview the displayed localhost URL. Refresh the browser manually after changes and stop with Ctrl+C.

matra init hello
cd hello
matra build
matra dev
Published npm package

This is experimental. Builds execute document JavaScript, so use trusted documents only. No OS sandbox or execution timeout is guaranteed. Campaign information and support dates will be announced separately.

First step

Use the CLI, Core, and HTML

Install exact versions and refer to the README and public API contract.

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.

MARKDOWNexample.md
---
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 })'
    }
  ]
})
```
HTMLgenerated output
<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 &amp;&amp; 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: &quot;dist&quot;, pages })</code></pre>
      </section>
    </main>
    <footer>
      <p>These package workflows are experimental; check each package&#39;s release notes.</p>
    </footer>
  </body>
</html>

Read and try

Choose your next step.

01

Examples

A minimal runnable path connecting Matra, JavaScript, and the HTML renderer.

View examples →

03

Packages

Roles and provisional usage examples for Core, CLI, HTML, and site-generation.

View packages →

Important

Distinguish stable and experimental scope.

The literate API does not provide compatibility guarantees, an OS sandbox, or a timeout guarantee. Review the public API contract first.

Public API contract