mdx-bundler is a high-performance library designed to compile and bundle MDX files along with their JavaScript/TypeScript dependencies, making it ideal for rendering dynamic content. The current stable version is 10.1.1. It maintains an active release cadence, with several minor and patch releases annually addressing bugs and introducing features, demonstrating ongoing development. A key differentiator is its use of esbuild, which enables extremely fast bundling, setting it apart from other MDX solutions. Unlike `next-mdx-remote`, `mdx-bundler` actively bundles file imports specified within MDX content, allowing for complex interactive components to be defined in separate files and imported directly. This capability makes it powerful for both build-time and on-demand, runtime content processing, offering scalability where each new MDX page does not necessarily increase build times.
npm install mdx-bundlerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to bundle MDX content with local dependencies, extract frontmatter, and render the resulting MDX component using `mdx-bundler` with server-side React rendering.
Upgrade your Node.js environment to version 18 or newer.
Review and update all custom remark and rehype plugins to ensure they are compatible with MDX v3 and the latest unified ecosystem versions.
Install esbuild as a direct dependency: `npm install esbuild` or `yarn add esbuild`.
Before calling `bundleMDX`, set `process.env.ESBUILD_BINARY_PATH` to the absolute path of the esbuild executable (e.g., `./node_modules/esbuild/esbuild.exe` for Windows or `./node_modules/esbuild/bin/esbuild` for Unix-like systems).
Ensure your consuming code uses `import { bundleMDX } from 'mdx-bundler';` and that your project is configured for ES Modules (e.g., `"type": "module"` in `package.json` or `.mjs` file extension).Install esbuild locally: `npm install esbuild` or `yarn add esbuild`.
Convert your consuming file to an ES Module by using `import { bundleMDX } from 'mdx-bundler';` and ensure your `package.json` has `"type": "module"` or the file ends with `.mjs`.Explicitly set `process.env.ESBUILD_BINARY_PATH` to the correct path for your platform, e.g., `./node_modules/esbuild/esbuild.exe` for Windows or `./node_modules/esbuild/bin/esbuild` for Linux/macOS, before calling `bundleMDX`.
Ensure `mdxOptions` is a function with the signature `(options: MDXOptions) => MDXOptions` and that all remark/rehype plugins are compatible with MDX v3 and the unified dependencies used by mdx-bundler v10+.