{
  "url": "https://unifast.dev/docs/packages/node/overview/",
  "locale": "en",
  "title": "@unifast/node",
  "description": "Node.js binding for the unifast Markdown/MDX compiler powered by native Rust",
  "section": "packages",
  "body": "## Overview\n\n`@unifast/node` is the primary entry point for using unifast in Node.js. It provides the [`compile()`](/docs/packages/node/compile) function that invokes the native Rust compiler via napi-rs for maximum performance. It also supports the plugin system, allowing HAST transforms to be applied in JavaScript after the Rust compilation step.\n\n## Installation\n\n> The native Rust addon must be pre-built. Run `cargo build -p unifast-bindings-node --release` if the native binary is not available.\n\n## Quick Start\n\n```ts\n\nconst result = compile(\"# Hello, **world**!\");\nconsole.log(result.output);\n// <h1 id=\"hello-world\">Hello, <strong>world</strong>!</h1>\n```\n\n## Plugin Pipeline\n\nWhen plugins are provided, `compile()` executes the following pipeline:\n\n1. **Extract plugins** - Separates `plugins` from the rest of the options\n2. **Merge options** - Deep-merges each plugin's `options` into the compile options\n3. **Force HAST** - If any plugin has a `hastTransform`, the native call uses `outputKind: \"hast\"`\n4. **Native compilation** - Calls the Rust compiler via napi-rs\n5. **HAST transforms** - Applies each plugin's `hastTransform` in order\n6. **Convert output** - If the user didn't request HAST output, converts back to HTML via `hastToHtml`\n\n## Built-in Plugins\n\nThe following plugin factory functions are included — no separate install needed:\n\n`gfm`, `frontmatter`, `sanitize`, `syntect`, `treeSitter`, `toc`, `externalLinks`, `autolinkHeadings`, `smartypants`, `wikiLink`, `codeImport`, `emoji`, `breaks`, `math`, `githubAlert`, `sectionize`, `directive`, `definitionList`, `rubyAnnotation`, `cjk`\n\n```ts\n\nconst result = compile(source, {\n  plugins: [gfm(), frontmatter(), syntect()],\n});\n```\n\n## Exports Summary\n\n| Export | Kind | Description |\n|--------|------|-------------|\n| `compile` | function | Compile Markdown/MDX to HTML or other formats |\n| `gfm`, `frontmatter`, ... | function | Built-in plugin factories (20 total) |\n| `hastToHtml` | function | HAST-to-HTML serializer (re-exported from `@unifast/core`) |\n| `CompileOptions` | type | Compilation configuration |\n| `CompileResult` | type | Compilation result |\n| `UnifastPlugin` | type | Plugin interface |\n| `TocEntry` | type | Table of contents entry |\n| `HastRoot` | type | HAST root node |\n| `HastElement` | type | HAST element node |\n| `HastText` | type | HAST text node |\n| `HastNode` | type | Union of all HAST node types |\n| `UnifastError` | class | Base error class |\n| `ParseError` | class | Parse error class |\n| `CompileError` | class | Compile error class |",
  "alternates": [
    {
      "locale": "en",
      "url": "https://unifast.dev/docs/packages/node/overview/",
      "api": "https://unifast.dev//api/docs/packages/node/overview.json"
    },
    {
      "locale": "ja",
      "url": "https://unifast.dev/ja/docs/packages/node/overview/",
      "api": "https://unifast.dev//api/ja/docs/packages/node/overview.json"
    },
    {
      "locale": "zh-CN",
      "url": "https://unifast.dev/zh-CN/docs/packages/node/overview/",
      "api": "https://unifast.dev//api/zh-CN/docs/packages/node/overview.json"
    },
    {
      "locale": "zh-TW",
      "url": "https://unifast.dev/zh-TW/docs/packages/node/overview/",
      "api": "https://unifast.dev//api/zh-TW/docs/packages/node/overview.json"
    },
    {
      "locale": "ko",
      "url": "https://unifast.dev/ko/docs/packages/node/overview/",
      "api": "https://unifast.dev//api/ko/docs/packages/node/overview.json"
    },
    {
      "locale": "fr",
      "url": "https://unifast.dev/fr/docs/packages/node/overview/",
      "api": "https://unifast.dev//api/fr/docs/packages/node/overview.json"
    },
    {
      "locale": "it",
      "url": "https://unifast.dev/it/docs/packages/node/overview/",
      "api": "https://unifast.dev//api/it/docs/packages/node/overview.json"
    },
    {
      "locale": "es",
      "url": "https://unifast.dev/es/docs/packages/node/overview/",
      "api": "https://unifast.dev//api/es/docs/packages/node/overview.json"
    },
    {
      "locale": "pt-BR",
      "url": "https://unifast.dev/pt-BR/docs/packages/node/overview/",
      "api": "https://unifast.dev//api/pt-BR/docs/packages/node/overview.json"
    },
    {
      "locale": "de",
      "url": "https://unifast.dev/de/docs/packages/node/overview/",
      "api": "https://unifast.dev//api/de/docs/packages/node/overview.json"
    },
    {
      "locale": "ru",
      "url": "https://unifast.dev/ru/docs/packages/node/overview/",
      "api": "https://unifast.dev//api/ru/docs/packages/node/overview.json"
    },
    {
      "locale": "hi",
      "url": "https://unifast.dev/hi/docs/packages/node/overview/",
      "api": "https://unifast.dev//api/hi/docs/packages/node/overview.json"
    },
    {
      "locale": "id",
      "url": "https://unifast.dev/id/docs/packages/node/overview/",
      "api": "https://unifast.dev//api/id/docs/packages/node/overview.json"
    },
    {
      "locale": "tr",
      "url": "https://unifast.dev/tr/docs/packages/node/overview/",
      "api": "https://unifast.dev//api/tr/docs/packages/node/overview.json"
    },
    {
      "locale": "vi",
      "url": "https://unifast.dev/vi/docs/packages/node/overview/",
      "api": "https://unifast.dev//api/vi/docs/packages/node/overview.json"
    }
  ]
}
