티스토리 수익 글 보기

티스토리 수익 글 보기

remark-mdx | MDX
Skip to navigation
4-5 minutes read

remark-mdx

remark plugin to support the MDX syntax (JSX, export/import, expressions).

Contents

What is this?

This package is a unified (remark) plugin to enable the extensions to markdown that MDX adds: JSX (<x/>), export/import (export x from 'y'), and expression {{1 + 1}}. You can use this plugin to add support for parsing and serializing them.

This plugin does not handle how MDX is compiled to JavaScript or evaluated and rendered to HTML. That’s done by @mdx-js/mdx.

When should I use this?

This plugin is useful if you’re dealing with the MDX syntax and integrating with remark, rehype, and the rest of unified. Some example use cases are when you want to lint the syntax or compile it to something other that JavaScript.

If you don’t use plugins and want to access the syntax tree, you can use mdast-util-from-markdown with mdast-util-mdx.

Typically though, you’d want to move a layer up: @mdx-js/mdx. That package is the core compiler for turning MDX into JavaScript which gives you the most control. Or even higher: if you’re using a bundler (Rollup, esbuild, webpack), or a site builder (Next.js) or build system (Vite) which comes with a bundler, you’re better off using an integration: see § Integrations.

Install

This package is ESM only. In Node.js (version 16+), install with npm:

Shell
npm install remark-mdx

In Deno with esm.sh:

TypeScript
import remarkMdx from 'https://esm.sh/remark-mdx@3'

In browsers with esm.sh:

HTML
<script type="module">
  import remarkMdx from 'https://esm.sh/remark-mdx@3?bundle'
</script>
MDX is made with ❤️ in Amsterdam, Boise, and around the 🌏
This site does not track you.
MIT © 2017-2025
Project on GitHub
Site on GitHub
Updates as RSS feed
Sponsor on OpenCollective