MDX.org.ai
Executable Codemdxe

Runtimes

MDX execution on Cloudflare Workers, locally through workerd

Runtimes

mdxe is Cloudflare-native. Arbitrary MDX code executes through Dynamic Worker Loaders (workerd) everywhere: in production via the worker_loaders binding, and locally via a Miniflare host worker. The Node and Bun CLIs are thin shells that boot workerd; there is no Node or Bun evaluation path.

The former @mdxe/node, @mdxe/bun, @mdxe/next, @mdxe/honox, @mdxe/electron, @mdxe/expo, @mdxe/slidev and @mdxe/remotion packages were removed and are deprecated on npm.

Available Runtimes

RuntimePackageUse Case
Workers@mdxe/workersCloudflare edge computing; @mdxe/workers/local runs the same code under Miniflare
Hono@mdxe/honoHTTP serving on Workers
Ink@mdxe/inkTerminal viewer

Choosing a Runtime

Edge Computing

For Cloudflare Workers, use @mdxe/workers:

import { execute } from '@mdxe/workers'
 
export default {
  fetch: async (request) => {
    const result = await execute(mdx)
    return new Response(result.html)
  },
}

Local Development

The same evaluator runs locally under Miniflare, so local behaviour matches production:

import { createLocalEvaluator } from '@mdxe/workers/local'
 
const evaluator = createLocalEvaluator()
const result = await evaluator.evaluate(mdx)
await evaluator.dispose()

HTTP Servers

For serving MDX over HTTP, use @mdxe/hono:

import { Hono } from 'hono'
import { mdx } from '@mdxe/hono'
 
const app = new Hono()
app.use('*', mdx({ root: './content' }))
export default app

CLI Applications

For terminal UIs, render to plain bytes and display them with the @mdxe/ink viewer. The viewer never renders MDX itself; it displays frames and handles input:

import { createInkViewer } from '@mdxe/ink'
 
const viewer = createInkViewer()
const handle = await viewer.mount(frames, {
  terminal: { stdout: process.stdout, stdin: process.stdin },
})
handle.onAction((action) => {
  /* quit | scroll | page | jump | select | back | search | insert | resize */
})

Universal API

All runtimes share a common API:

interface ExecuteResult {
  /** Rendered content */
  content: ReactElement | string
 
  /** Parsed frontmatter */
  frontmatter: Record<string, unknown>
 
  /** Export values from MDX */
  exports: Record<string, unknown>
 
  /** Table of contents */
  toc: TocEntry[]
}
 
interface ExecuteOptions {
  /** Custom React components */
  components?: Record<string, Component>
 
  /** Variables accessible in MDX scope */
  scope?: Record<string, unknown>
 
  /** MDX compiler options */
  mdxOptions?: MDXOptions
}

Feature Comparison

FeatureWorkersHonoInk
React Components✓✓✓
Streaming✓✓-
Hot Reload✓ (Miniflare)✓ (Miniflare)✓
File System--✓

On this page