Compiler API
Use the compiler directly in any TypeScript or JavaScript runtime.
Install
npm install @nml-lang/compiler-ts
nmlCompiler.render
The high-level async render method. Takes NML source, a context object, and an optional options object.
import { nmlCompiler } from "@nml-lang/compiler-ts";
| Option | Description |
|---|---|
| basePath | Base directory for resolving @include paths |
| readFile | Async function to read a file by path — filesystem, R2, D1, etc. |
Cloudflare Workers Example
import { Hono } from "hono";
Low-Level API
Access the AST parser and HTML generator directly for custom pipelines.
import {
Error Handling
Parse errors throw NMLParserError with exact source location.
try {
MCP Server
The @nml-lang/mcp-server exposes compile, lint, and list-components tools to any MCP-compatible AI assistant (Windsurf, Claude, Cursor, Zed).
Windsurf / Claude / Cursor — mcp_config.json
{