.mdx template against a props object. The snippets below use the Node API (load + transform + stringify) — if you need to bundle templates into a web app, wire up your bundler’s MDX loader separately.
Install
- npm
- yarn
- pnpm
Render a template (Node)
Givenmy-template.mdx:
my-template.mdx
load(path)— parses the.mdxfile from disk into an AST.transform(ast, props)— evaluates expressions and tag plugins againstprops.stringify(ast)— serializes the rendered AST back to a Markdown/text string.
Render a template (bundled / web)
When your.mdx is bundled at build time (Next.js, Vite, etc.) and the default export is an AST, you can skip load:
.mdx into a JS module requires an MDX bundler or loader appropriate to your framework — TemplateDX does not ship one.
Next steps
Syntax
Tags, expressions, components, and XML passthrough
Variables
Props and scope resolution
Custom tags
Write your own
<Tag> pluginsCustom filters
Extend expression evaluation with filters