# @mintlify/mdx

> Markdown parser from Mintlify

Latest version **4.0.6** (published 2026-09-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mintlify/mdx
pnpm add @mintlify/mdx
yarn add @mintlify/mdx
bun add @mintlify/mdx
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.0.6 |
| Published | 2026-09-23 |
| First published | 2023-11-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 17 |
| Unpacked size | 461.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 204 |
| Author | Mintlify, Inc. |
| Maintainers | dks333, hanmint, hahnbee, shouchem-mintlify, kylefinken, lucaspunz |

## Links

- npm: https://www.npmjs.com/package/@mintlify/mdx
- Repository: https://github.com/mintlify/mdx
- Homepage: https://github.com/mintlify/mdx#readme
- Issues: https://github.com/mintlify/mdx/issues
- npm.io page: https://npm.io/package/@mintlify/mdx

## Dependencies (17)

- [shiki](https://npm.io/package/shiki.md) ^3.23.0
- [arktype](https://npm.io/package/arktype.md) ^2.1.26
- [unified](https://npm.io/package/unified.md) ^11.0.0
- [twoslash](https://npm.io/package/twoslash.md) ^0.3.4
- [remark-gfm](https://npm.io/package/remark-gfm.md) ^4.0.0
- [remark-math](https://npm.io/package/remark-math.md) ^6.0.0
- [rehype-katex](https://npm.io/package/rehype-katex.md) ^7.0.1
- [mdast-util-gfm](https://npm.io/package/mdast-util-gfm.md) ^3.1.0
- [unist-util-visit](https://npm.io/package/unist-util-visit.md) ^5.0.0
- [@shikijs/twoslash](https://npm.io/package/@shikijs/twoslash.md) ^3.23.0
- [mdast-util-mdx-jsx](https://npm.io/package/mdast-util-mdx-jsx.md) ^3.2.0
- [mdast-util-to-hast](https://npm.io/package/mdast-util-to-hast.md) ^13.2.0
- [remark-smartypants](https://npm.io/package/remark-smartypants.md) ^3.0.2
- [hast-util-to-string](https://npm.io/package/hast-util-to-string.md) ^3.0.1
- [@shikijs/transformers](https://npm.io/package/@shikijs/transformers.md) ^3.23.0
- [next-mdx-remote-client](https://npm.io/package/next-mdx-remote-client.md) ^2.1.11
- [mdast-util-from-markdown](https://npm.io/package/mdast-util-from-markdown.md) ^2.0.2

## Recent versions

- 4.0.6 (latest) — 2026-09-23
- 2.0.12-canary.4 (canary) — 2025-09-24
- 4.0.5 — 2026-09-23
- 4.0.4 — 2026-09-23
- 4.0.3 — 2026-09-21
- 4.0.2 — 2026-08-06
- 4.0.1 — 2026-07-29
- 4.0.0 — 2025-12-03
- 3.0.4 — 2025-11-20
- 3.0.3 — 2025-11-15
- 3.0.2 — 2025-11-14
- 3.0.1 — 2025-10-28
- 3.0.0 — 2025-10-01
- 2.0.13 — 2025-09-26
- 2.0.12 — 2025-09-25
- … 70 more at https://npm.io/package/@mintlify/mdx/versions

## README

<div align="center">
  <a href="https://mintlify.com">
    <img
      src="https://res.cloudinary.com/mintlify/image/upload/v1665385627/logo-rounded_zuk7q1.svg"
      alt="Mintlify Logo"
      height="64"
    />
  </a>
  <br />
  <p>
    <h3>
      <b>
        Mint
      </b>
    </h3>
  </p>
  <p>
    <b>
      Open source docs builder that's beautiful, fast, and easy to work with.
    </b>
  </p>
  <p>

![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen?logo=github) [![Tweet](https://img.shields.io/twitter/url?url=https%3A%2F%2Fmintlify.com%2F)](https://twitter.com/intent/tweet?url=&text=Check%20out%20%40mintlify)

  </p>
</div>

# Mintlify's markdown parser

**@mintlify/mdx** is a thin layer on top of [next-mdx-remote-client](https://github.com/ipikuka/next-mdx-remote-client) that provides a better developer experience for Next.js users by adding support for syntax highlighting.

## Installation

```bash
# using npm
npm i @mintlify/mdx

# using yarn
yarn add @mintlify/mdx

# using pnpm
pnpm add @mintlify/mdx
```

## Examples

### Next.js pages router

[You can check the example app here](https://github.com/mintlify/mdx/tree/main/examples/pages-router).

1. Call the `serialize` function inside `getStaticProps` and return the `mdxSource` object.

   ```tsx
   export const getStaticProps = (async () => {
     const mdxSource = await serialize({
       source: '## Markdown H2',
     });

     if ('error' in mdxSource) {
       // handle error case
     }

     return { props: { mdxSource } };
   }) satisfies GetStaticProps<{
     mdxSource: SerializeSuccess;
   }>;
   ```

2. Pass the `mdxSource` object as props inside the `MDXComponent`.

   ```tsx
   export default function Page({ mdxSource }: InferGetStaticPropsType<typeof getStaticProps>) {
     return <MDXClient {...mdxSource} />;
   }
   ```

### Next.js app router

[You can check the example app here](https://github.com/mintlify/mdx/tree/main/examples/app-router).

1. Use the `MDXRemote` component directly inside your async React Server Component.

   ```tsx
   import { MDXRemote } from '@mintlify/mdx';

   export default async function Home() {
     const source: `---
      title: Title
      ---

      ## Markdown H2
      `;

     return (
       <article className="prose mx-auto py-8">
         <MDXRemote source={source} parseFrontmatter />
       </article>
     );
   }
   ```

## APIs

Similar to [next-mdx-remote-client](https://github.com/ipikuka/next-mdx-remote-client), this package exports the following APIs:

- `serialize` - a function that compiles MDX source to SerializeResult.
- `MDXClient` - a component that renders SerializeSuccess on the client.
- `MDXRemote` - a component that both serializes and renders the source - should be used inside async React Server Component.

### serialize

```tsx
import { serialize } from '@mintlify/mdx';

const mdxSource = await serialize({
  source: '## Markdown H2',
  mdxOptions: {
    remarkPlugins: [
      // Remark plugins
    ],
    rehypePlugins: [
      // Rehype plugins
    ],
  },
});
```

### MDXClient

```tsx
'use client';

import { MDXClient } from '@mintlify/mdx';

<MDXClient
  components={
    {
      // Your custom components
    }
  }
  {...mdxSource}
/>;
```

### MDXRemote

```tsx
import { MDXRemote } from '@mintlify/mdx';

<MDXRemote
  source="## Markdown H2"
  mdxOptions={{
    remarkPlugins: [
      // Remark plugins
    ],
    rehypePlugins: [
      // Rehype plugins
    ],
  }}
  components={
    {
      // Your custom components
    }
  }
/>;
```

<div align="center">
  <p>
    <sub>
      Built with ❤︎ by
      <a href="https://mintlify.com">
        Mintlify
      </a>
    </sub>
  </p>
</div>

---
_Source: https://npm.io/package/@mintlify/mdx · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
