Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsMay 16, 2026·3 min de lecture

MDX — Markdown for the Component Era

MDX lets you use JSX components directly inside Markdown documents, enabling interactive and dynamic content in documentation sites, blogs, and design systems.

Prêt pour agents

Cet actif peut être lu et installé directement par les agents

TokRepo expose une commande CLI universelle, un contrat d'installation, le metadata JSON, un plan selon l'adaptateur et le contenu raw pour aider les agents à juger l'adaptation, le risque et les prochaines actions.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
MDX
Commande CLI universelle
npx tokrepo install 08b5e23d-5166-11f1-9bc6-00163e2b0d79

Introduction

MDX is an authoring format that combines the simplicity of Markdown with the power of JSX. It allows you to import and render React (or other framework) components directly within Markdown content, making it the standard for interactive documentation, blogs, and content-heavy applications.

What MDX Does

  • Parses Markdown with embedded JSX expressions and component imports
  • Compiles MDX files into framework components (React, Preact, Vue, Svelte)
  • Supports standard Markdown syntax including GFM (tables, task lists, footnotes)
  • Allows passing props and data to embedded components at render time
  • Integrates with remark and rehype plugin ecosystems for content transformation

Architecture Overview

MDX uses a pipeline: the MDX compiler parses source into an AST using micromark (Markdown) and acorn (JavaScript), then applies remark/rehype plugins for transformations, and finally serializes the AST into a JavaScript module that exports a component function. This pipeline runs at build time, producing static or server-rendered output with no client runtime cost for static content.

Self-Hosting & Configuration

  • Add @mdx-js/loader to webpack or use the Vite plugin @mdx-js/rollup
  • Configure via mdx options in your bundler (remarkPlugins, rehypePlugins)
  • Use next.config.mjs with @next/mdx for Next.js integration
  • Set providerImportSource to customize the component provider
  • Add TypeScript types with @types/mdx for editor autocompletion

Key Features

  • Full interop with any component framework via JSX
  • remark/rehype plugin system for syntax extensions and transformations
  • Compiles to static output with zero client JS for non-interactive content
  • Supports expressions, imports, and exports inside Markdown
  • Works with content layers like Contentlayer, Velite, or Fumadocs

Comparison with Similar Tools

  • Markdoc — Stripe's Markdoc uses custom tag syntax; MDX uses standard JSX familiar to React developers
  • Astro Components — Astro's .astro files mix HTML and JS; MDX focuses specifically on Markdown-first content
  • remark-html — remark outputs static HTML; MDX produces interactive component trees
  • Docusaurus Markdown — Docusaurus uses MDX under the hood for its documentation features
  • reStructuredText — RST is powerful but Python-ecosystem-only; MDX works across JS frameworks

FAQ

Q: Does MDX add runtime overhead? A: No. MDX compiles at build time. Static content ships as plain HTML with zero additional JavaScript.

Q: Can I use MDX with Vue or Svelte? A: Yes. MDX v3 supports multiple JSX runtimes. Configure the jsxImportSource option for your framework.

Q: How do I add syntax highlighting to code blocks? A: Use rehype plugins like rehype-shiki or rehype-prism-plus in your MDX pipeline configuration.

Q: Is MDX compatible with standard Markdown files? A: Yes. Any valid Markdown file is valid MDX. You can rename .md to .mdx and add components incrementally.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires