## File: README.md

[![MDX][githubusercontent-logo]][website]

# Markdown for the component era

[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]

[MDX][website] is an authorable format that lets you seamlessly write JSX in
your markdown documents.
You can import components, such as interactive charts or alerts, and embed them
within your content.
This makes writing long-form content with components a blast.
🚀

```mdx
import {Chart} from './snowfall.js'
export const year = 2013

# Last year’s snowfall

In {year}, the snowfall was above average.
It was followed by a warm spring which caused
flood conditions in many of the nearby rivers.

<Chart year={year} color="#fcb32c" />
```

See [§ What is MDX](https://mdxjs.com/docs/what-is-mdx/) for more info on the
format.
See [§ Playground](https://mdxjs.com/playground/) to try it out.

## What is this?

This GitHub repository contains several packages for compiling the MDX format to
JavaScript, integrating with bundlers such as webpack and Rollup, and for using
it with frameworks such as React, Preact, and Vue.

See [§ Getting started](https://mdxjs.com/getting-started/) for how to
integrate MDX into your project.

## Security

See [§ Security][security] on our site for information.

## Contribute

See [§ Contribute][contribute] on our site for ways to get started.
See [§ Support][support] for ways to get help.

This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.

## Sponsor

See [§ Sponsor][sponsor] on our site for how to help financially.



| [Vercel](https://vercel.com)
  [](https://vercel.com) | [Motif](https://motif.land)
  [](https://motif.land) | [HashiCorp](https://www.hashicorp.com)
  [](https://www.hashicorp.com) | [GitBook](https://www.gitbook.com)
  [](https://www.gitbook.com) | [Gatsby](https://www.gatsbyjs.org)
  [](https://www.gatsbyjs.org) |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| [Netlify](https://www.netlify.com)
  
  [](https://www.netlify.com) | [Coinbase](https://www.coinbase.com)
  [](https://www.coinbase.com) | [ThemeIsle](https://themeisle.com)
  [](https://themeisle.com) | [Expo](https://expo.io)
  [](https://expo.io) | [Boost Note](https://boostnote.io)
  [](https://boostnote.io) | [Markdown Space](https://markdown.space)
  [](https://markdown.space) | [Holloway](https://www.holloway.com)
  [](https://www.holloway.com) |  |  |
| [**You?**](https://opencollective.com/unified) |  |  |  |  |  |  |  |  |



## License

[MIT][] © Compositor and [Vercel][]

[backers-badge]: https://opencollective.com/unified/backers/badge.svg

[build]: https://github.com/mdx-js/mdx/actions

[build-badge]: https://github.com/mdx-js/mdx/workflows/main/badge.svg

[chat]: https://github.com/mdx-js/mdx/discussions

[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg

[coc]: https://github.com/mdx-js/.github/blob/main/code-of-conduct.md

[collective]: https://opencollective.com/unified

[contribute]: https://mdxjs.com/community/contribute/

[coverage]: https://codecov.io/github/mdx-js/mdx

[coverage-badge]: https://img.shields.io/codecov/c/github/mdx-js/mdx/main.svg

[githubusercontent-logo]: https://raw.githubusercontent.com/mdx-js/.github/5a63e56/image/cover.svg?sanitize=true

[mit]: license

[security]: https://mdxjs.com/getting-started/#security

[sponsor]: https://mdxjs.com/community/sponsor/

[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg

[support]: https://mdxjs.com/community/support/

[vercel]: https://vercel.com

[website]: https://mdxjs.com

---

## File: Readme.md

[![MDX][githubusercontent-logo]][website]

# Markdown for the component era

[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]

[MDX][website] is an authorable format that lets you seamlessly write JSX in
your markdown documents.
You can import components, such as interactive charts or alerts, and embed them
within your content.
This makes writing long-form content with components a blast.
🚀

```mdx
import {Chart} from './snowfall.js'
export const year = 2013

# Last year’s snowfall

In {year}, the snowfall was above average.
It was followed by a warm spring which caused
flood conditions in many of the nearby rivers.

<Chart year={year} color="#fcb32c" />
```

See [§ What is MDX](https://mdxjs.com/docs/what-is-mdx/) for more info on the
format.
See [§ Playground](https://mdxjs.com/playground/) to try it out.

## What is this?

This GitHub repository contains several packages for compiling the MDX format to
JavaScript, integrating with bundlers such as webpack and Rollup, and for using
it with frameworks such as React, Preact, and Vue.

See [§ Getting started](https://mdxjs.com/getting-started/) for how to
integrate MDX into your project.

## Security

See [§ Security][security] on our site for information.

## Contribute

See [§ Contribute][contribute] on our site for ways to get started.
See [§ Support][support] for ways to get help.

This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.

## Sponsor

See [§ Sponsor][sponsor] on our site for how to help financially.



| [Vercel](https://vercel.com)
  [](https://vercel.com) | [Motif](https://motif.land)
  [](https://motif.land) | [HashiCorp](https://www.hashicorp.com)
  [](https://www.hashicorp.com) | [GitBook](https://www.gitbook.com)
  [](https://www.gitbook.com) | [Gatsby](https://www.gatsbyjs.org)
  [](https://www.gatsbyjs.org) |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| [Netlify](https://www.netlify.com)
  
  [](https://www.netlify.com) | [Coinbase](https://www.coinbase.com)
  [](https://www.coinbase.com) | [ThemeIsle](https://themeisle.com)
  [](https://themeisle.com) | [Expo](https://expo.io)
  [](https://expo.io) | [Boost Note](https://boostnote.io)
  [](https://boostnote.io) | [Markdown Space](https://markdown.space)
  [](https://markdown.space) | [Holloway](https://www.holloway.com)
  [](https://www.holloway.com) |  |  |
| [**You?**](https://opencollective.com/unified) |  |  |  |  |  |  |  |  |



## License

[MIT][] © Compositor and [Vercel][]

[backers-badge]: https://opencollective.com/unified/backers/badge.svg

[build]: https://github.com/mdx-js/mdx/actions

[build-badge]: https://github.com/mdx-js/mdx/workflows/main/badge.svg

[chat]: https://github.com/mdx-js/mdx/discussions

[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg

[coc]: https://github.com/mdx-js/.github/blob/main/code-of-conduct.md

[collective]: https://opencollective.com/unified

[contribute]: https://mdxjs.com/community/contribute/

[coverage]: https://codecov.io/github/mdx-js/mdx

[coverage-badge]: https://img.shields.io/codecov/c/github/mdx-js/mdx/main.svg

[githubusercontent-logo]: https://raw.githubusercontent.com/mdx-js/.github/5a63e56/image/cover.svg?sanitize=true

[mit]: license

[security]: https://mdxjs.com/getting-started/#security

[sponsor]: https://mdxjs.com/community/sponsor/

[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg

[support]: https://mdxjs.com/community/support/

[vercel]: https://vercel.com

[website]: https://mdxjs.com

---

## File: readme.md

[![MDX][githubusercontent-logo]][website]

# Markdown for the component era

[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]

[MDX][website] is an authorable format that lets you seamlessly write JSX in
your markdown documents.
You can import components, such as interactive charts or alerts, and embed them
within your content.
This makes writing long-form content with components a blast.
🚀

```mdx
import {Chart} from './snowfall.js'
export const year = 2013

# Last year’s snowfall

In {year}, the snowfall was above average.
It was followed by a warm spring which caused
flood conditions in many of the nearby rivers.

<Chart year={year} color="#fcb32c" />
```

See [§ What is MDX](https://mdxjs.com/docs/what-is-mdx/) for more info on the
format.
See [§ Playground](https://mdxjs.com/playground/) to try it out.

## What is this?

This GitHub repository contains several packages for compiling the MDX format to
JavaScript, integrating with bundlers such as webpack and Rollup, and for using
it with frameworks such as React, Preact, and Vue.

See [§ Getting started](https://mdxjs.com/getting-started/) for how to
integrate MDX into your project.

## Security

See [§ Security][security] on our site for information.

## Contribute

See [§ Contribute][contribute] on our site for ways to get started.
See [§ Support][support] for ways to get help.

This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.

## Sponsor

See [§ Sponsor][sponsor] on our site for how to help financially.



| [Vercel](https://vercel.com)
  [](https://vercel.com) | [Motif](https://motif.land)
  [](https://motif.land) | [HashiCorp](https://www.hashicorp.com)
  [](https://www.hashicorp.com) | [GitBook](https://www.gitbook.com)
  [](https://www.gitbook.com) | [Gatsby](https://www.gatsbyjs.org)
  [](https://www.gatsbyjs.org) |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| [Netlify](https://www.netlify.com)
  
  [](https://www.netlify.com) | [Coinbase](https://www.coinbase.com)
  [](https://www.coinbase.com) | [ThemeIsle](https://themeisle.com)
  [](https://themeisle.com) | [Expo](https://expo.io)
  [](https://expo.io) | [Boost Note](https://boostnote.io)
  [](https://boostnote.io) | [Markdown Space](https://markdown.space)
  [](https://markdown.space) | [Holloway](https://www.holloway.com)
  [](https://www.holloway.com) |  |  |
| [**You?**](https://opencollective.com/unified) |  |  |  |  |  |  |  |  |



## License

[MIT][] © Compositor and [Vercel][]

[backers-badge]: https://opencollective.com/unified/backers/badge.svg

[build]: https://github.com/mdx-js/mdx/actions

[build-badge]: https://github.com/mdx-js/mdx/workflows/main/badge.svg

[chat]: https://github.com/mdx-js/mdx/discussions

[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg

[coc]: https://github.com/mdx-js/.github/blob/main/code-of-conduct.md

[collective]: https://opencollective.com/unified

[contribute]: https://mdxjs.com/community/contribute/

[coverage]: https://codecov.io/github/mdx-js/mdx

[coverage-badge]: https://img.shields.io/codecov/c/github/mdx-js/mdx/main.svg

[githubusercontent-logo]: https://raw.githubusercontent.com/mdx-js/.github/5a63e56/image/cover.svg?sanitize=true

[mit]: license

[security]: https://mdxjs.com/getting-started/#security

[sponsor]: https://mdxjs.com/community/sponsor/

[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg

[support]: https://mdxjs.com/community/support/

[vercel]: https://vercel.com

[website]: https://mdxjs.com

---

## File: docs/blog/conf.mdx

import {Note} from '../_component/note.jsx'

export const info = {
  author: [
    {github: 'johno', name: 'John Otander'}
  ],
  modified: new Date('2025-01-27'),
  published: new Date('2020-07-31')
}

<Note type="legacy">
  **Note**: This is an old blog post.
  The below is kept as is for historical purposes.
</Note>

# MDXConf

MDXConf is a free and online conference for the MDX community.
Whether you’re just learning about MDX or an expert, there’ll be something for
you! {/* more */}

August 24th, 2020 at 8am PDT/3pm UST  Online • Free

## Watch

The conference is now over, but you can still watch the recordings!

[Watch the talks →](https://egghead.io/playlists/mdx-conf-3fc2)

## About

Join us for the first MDX conference!
We’ll stream it directly to you, for free.

MDX has grown rapidly since the [first commit][] two and a half years ago.
We’d like to celebrate our accomplishments so far, and talk about what lies
ahead.
We’ve got lots of plans.

Learn how MDX increases developer productivity, improves educational
content authoring, and even peek behind the curtains to see how MDX works.

## Speakers

### Chris Biscardi

]

Keynote: The past, present, and future of MDX

### Monica Powell



Migrating to MDX

### Laurie Barth



MDX v2 syntax

### Cole Bemis



Demystifying MDX

### Prince Wilson



Personal site playgrounds

### Kathleen McMahon



Digital gardening with MDX magic

### Rodrigo Pombo



The X in MDX

### Jonathan Bakebwa



MDX and Vue/Nuxt

## Sign up

<Note type="legacy">
  **Note**: Sign up is closed.
</Note>

## FAQ

### What if I can’t make it on August 24th?

We’ll miss you, but you won’t miss out!
All talks will be recorded and released the day of the conference.
You can catch up with the talks, or rewatch them, whenever convenient.

### Will the talks be transcribed?

Yes.

### Is there a code of conduct?

Absolutely.
We’re dedicated to providing a harassment-free experience for everyone.
We will not tolerate harassment of participants in any form.
We’ve adopted the [Party Corgi Network’s Code of Conduct][coc].
We will have moderators to ensure that the code of conduct is followed.

### Do you have a different question?

Reach out to us.

[coc]: https://github.com/partycorgi/partycorgi/blob/corgi/CODE_OF_CONDUCT.md

[first commit]: https://github.com/mdx-js/mdx/commit/dee47dc20b08d534132e3b966cdccf3b88c7bca5

---

## File: docs/blog/custom-pragma.mdx

import {Note} from '../_component/note.jsx'

export const info = {
  author: [
    {github: 'christopherbiscardi', name: 'Chris Biscardi'}
  ],
  modified: new Date('2021-11-01'),
  published: new Date('2019-03-11')
}

<Note type="legacy">
  **Note**: This is an old blog post.
  The steps described in it are no longer performed by MDX.
  It now uses an JavaScript AST first rather than generating a string of JSX.
  It is also no longer required for extra glue code, that combines MDX with a
  specific framework, to be used on the client.
  See [§ How MDX works](/docs/using-mdx/#how-mdx-works)
  and [¶ Architecture](/packages/mdx/#architecture) for more info.
  The below is kept as is for historical purposes.
</Note>

# Custom pragma

`MDXTag`, for those that aren’t aware, is a critical piece in the way
MDX replaces HTML primitives like `` and `<h1>` with custom React
Components.
[I’ve previously
written](https://www.christopherbiscardi.com/post/codeblocks-mdx-and-mdx-utils)
about the way `MDXTag` works when trying to replace the `` tag
with a custom code component.
[mdx-utils](https://github.com/ChristopherBiscardi/gatsby-mdx/blob/00769a1b72455f40843cd2f09ee34fd63b009fb2/packages/mdx-utils/index.js)
contains the methodology for pulling the props around appropriately
through the `MDXTag` elements that are inbetween `pre` and `code`.

{/* more */}

```tsx
exports.preToCodeBlock = preProps => {
  if (
    // children is MDXTag
    preProps.children &&
    // MDXTag props
    preProps.children.props &&
    // if MDXTag is going to render a <code>
    preProps.children.props.name === 'code'
  ) {
    // we have a <code> situation
    const {
      children: codeString,
      props: {className, ...props}
    } = preProps.children.props

    return {
      codeString: codeString.trim(),
      language: className && className.split('-')[1],
      ...props
    }
  }
  return undefined
}
```

So `MDXTag` is a real Component in the middle of all of the other MDX
rendered elements.
All of the code is included here for reference.

```tsx
import React, {Component} from 'react'

import {withMDXComponents} from './mdx-provider'

const defaults = {
  inlineCode: 'code',
  wrapper: 'div'
}

class MDXTag extends Component {
  render() {
    const {
      name,
      parentName,
      props: childProps = {},
      children,
      components = {},
      Layout,
      layoutProps
    } = this.props

    const Component =
      components[`${parentName}.${name}`] ||
      components[name] ||
      defaults[name] ||
      name

    if (Layout) {
      return (
        <Layout components={components} {...layoutProps}>
          <Component {...childProps}>{children}</Component>
        </Layout>
      )
    }

    return <Component {...childProps}>{children}</Component>
  }
}

export default withMDXComponents(MDXTag)
```

`MDXTag` is used in the hast to estree conversion,
which is the final step in the MDX AST pipeline.
Every renderable element is wrapped in an `MDXTag`, and `MDXTag` handles
rendering the element later.

```tsx
return `<MDXTag name="${node.tagName}" components={components}${
  parentNode.tagName ? ` parentName="${parentNode.tagName}"` : ''
}${props ? ` props={${props}}` : ''}>${children}</MDXTag>`
```

## A concrete example

The following MDX

```mdx
# a title

    and such

testing
```

turns into the following React code

```tsx
export default ({components, ...props}) => (
  <MDXTag name="wrapper" components={components}>
    <MDXTag name="h1" components={components}>{`a title`}</MDXTag>{' '}
    <MDXTag name="pre" components={components}>
      <MDXTag
        name="code"
        components={components}
        parentName="pre"
        props={{metaString: null}}
      >{`and such `}</MDXTag>
    </MDXTag>{' '}
    <MDXTag name="p" components={components}>{`testing`}</MDXTag>
  </MDXTag>
)
```

resulting in the following HTML

```html

  <h1>a title</h1>
  
    `and such`
  
  testing

```

## createElement

With the new approach, the above MDX transforms into this new React code

```tsx
const layoutProps = {}
export default function MDXContent({components, ...props}) {
  return (
    <MDXLayout
      {...layoutProps}
      {...props}
      components={components}
      mdxType="MDXLayout"
    >
      <h1>{`a title`}</h1>
      
        <code parentName="pre" {...{}}>{`and such
`}</code>
      
      {`testing`}
    </MDXLayout>
  )
}

MDXContent.isMDXComponent = true
```

Notice how now the React elements are plainly readable without
wrapping `MDXTag`.

Now that we’ve cleaned up the intermediary representation, we need to
make sure that we have the same functionality as the old `MDXTag`.
This is done through a custom `createElement` implementation.
Typically when using React, we use `React.createElement` to render the elements
on screen.
This is even true if you’re using JSX because JSX tags such as `` compile
to `createElement` calls.
So this time instead of using `React.createElement` we’ll be using our own.

Reproduced here is our `createElement` function and the logic for how
we decide whether or not MDX should take over the rendering of the
`createElement` call.

```tsx
export default function (type, props) {
  const args = arguments
  const mdxType = props && props.mdxType

  if (typeof type === 'string' || mdxType) {
    const argsLength = args.length

    const createElementArgArray = new Array(argsLength)
    createElementArgArray[0] = MDXCreateElement

    const newProps = {}
    for (let key in props) {
      if (hasOwnProperty.call(props, key)) {
        newProps[key] = props[key]
      }
    }
    newProps.originalType = type
    newProps[TYPE_PROP_NAME] = typeof type === 'string' ? type : mdxType

    createElementArgArray[1] = newProps

    for (let i = 2; i < argsLength; i++) {
      createElementArgArray[i] = args[i]
    }

    return React.createElement.apply(null, createElementArgArray)
  }

  return React.createElement.apply(null, args)
}
```

## Vue

One really cool application of the new output format using a custom
`createElement` is that we can now write versions of it for Vue and other
frameworks.
Since the pragma insertion is the responsibility of the webpack (or other
bundlers) loader, swapping the pragma can be an option in mdx-loader as long as
we have a Vue `createElement` to point to.

---

## File: docs/blog/index.mdx

{
  /**
   * @import {Item} from '../_component/sort.js'
   */

  /**
   * @typedef Props
   * @property {Item} navigationTree
   */
}

import assert from 'node:assert/strict'
import {BlogGroup} from '../_component/blog.jsx'

export const info = {
  author: [{name: 'MDX Contributors'}],
  modified: new Date('2024-07-04'),
  published: new Date('2021-11-01')
}
export const navExcludeGroup = true
export const navigationSortItems = 'navSortSelf,meta.published:desc'
export const navSortSelf = 7

# Blog

The latest news about MDX.

{
  (function () {
    const navigationTree = props.navigationTree
    const category = navigationTree.children.find(function (item) {
      return item.name === '/blog/'
    })
    assert(category)

    return (
      <nav>
        
      </nav>
    )
  })()
}

---

## File: docs/blog/shortcodes.mdx

import {Note} from '../_component/note.jsx'

export const info = {
  author: [
    {github: 'johno', name: 'John Otander'}
  ],
  modified: new Date('2021-11-01'),
  published: new Date('2019-05-14')
}

<Note type="legacy">
  **Note**: This is an old blog post.
  The features described in it are currently documented at
  [§ MDX provider](/docs/using-mdx/#mdx-provider).
  The below is kept as is for historical purposes.
</Note>

# Shortcodes

An exciting new feature in MDX v1 is global shortcodes.
This allows you to expose components to all of your documents in your app or
website.
This is a useful feature for common components like YouTube embeds, Twitter
cards, or anything else frequently used in your documents.

{/* more */}

If you have an application wrapper for your MDX documents
you can add in components with the `MDXProvider`:

```tsx path="src/App.js"
import React from 'react'
import {MDXProvider} from '@mdx-js/react'
import {TomatoBox, Twitter, YouTube} from './ui'

const shortcodes = {TomatoBox, Twitter, YouTube}

export default ({children}) => (
  <MDXProvider components={shortcodes}>{children}</MDXProvider>
)
```

Then, any MDX document that’s wrapped in `App` has access to `YouTube`,
`Twitter`, and `TomatoBox`.
Shortcodes are nothing more than components, so you can reference them anywhere
in an MDX document with JSX.

```mdx path="example.mdx"
# Hello world!

Here’s a YouTube shortcode:

<YouTube tweetId="1234" />

Here’s a YouTube shortcode wrapped in TomatoBox:

<TomatoBox>
  <YouTube videoId="1234" />
</TomatoBox>
```

That’s it.
🎉 🚀

Huge thanks to [Chris Biscardi](https://christopherbiscardi.com)
for building out most of this functionality.

---

## File: docs/blog/v1.mdx

import {Note} from '../_component/note.jsx'

export const info = {
  author: [
    {github: 'johno', name: 'John Otander'}
  ],
  modified: new Date('2025-01-27'),
  published: new Date('2019-04-11')
}

<Note type="legacy">
  **Note**: This is an old blog post.
  [ZEIT is now Vercel](https://rauchg.com/2020/vercel).
  An “`@mdx` pragma” is no longer needed.
  The below is kept as is for historical purposes.
</Note>

# MDX goes stable

It’s been a year and a half since the first MDX commit and a year since MDX was
first announced at ZEIT Day.
MDX is a radical paradigm shift in how to write immersive content using
components.
It’s an open, [authorable format](https://johno.com/authorable-format) that
makes it *fun* to write again.

{/* more */}

Since announcing MDX we’ve been working on numerous bug fixes, new features,
better parsing, and integration tests.
Now, we think it’s ready.
**We’re happy to finally release v1!**

## 🎉 What’s new?

Here’s a rough breakdown on what we’ve been working on:

### Parsing

MDX document parsing is significantly improved.
We won’t get into the nitty gritty here, but we’ve seen how MDX is used in
real-world projects, integrated the edge cases we came across into our test
suite, and now handle JSX, imports, and exports much more intuitively.
Please open an issue if you find a case we haven’t covered!😸

### remark-mdx

`remark-mdx` is the syntactic extension for MDX in remark.
It provides the parsing functionality for MDX as a
*[remark](https://github.com/remarkjs/remark) plugin*.
That sounds a bit meta.
What it means is that before we had the syntax parsing bits *in* the library
(unusable from the outside), and now it’s externalized (usable from the
outside).
This is useful if you want to inspect or transform MDX documents.
For example, it allows tools like prettier to use the exact same parser used by
MDX core.
Or you could use `remark-mdx` in combination with
[remark-lint](https://github.com/remarkjs/remark-lint) to check your MDX.

### Custom pragma

With v1 we’ve moved away from using `MDXTag` and are using a custom pragma which
wraps `React.createElement`.
We decided to update this approach so the JSX output is more legible,
lighterweight, and more customizable.
**This means MDX can be used with any React, Vue, Preact, or any other library
with JSX support**.

Special thanks to [@christopherbiscardi][christopherbiscardi]
for implementing this feature.

[Read the blog post](/blog/custom-pragma/)

### 📚 Documentation

**Good libraries need great docs**, so we’ve been working on adding content and
improving the overall documentation website experience.

* Search (thanks Algolia)
* [Guides](/guides/)
* [Automatic deployment via ZEIT][zeit]
* [Custom Gatsby theme][gatsbyjs]
* Reorganization of docs for intuitiveness
* Full page rewrites to improve clarity

Special thanks to [@jxnblk](https://github.com/jxnblks) and
[@wooorm][wooorm] for their help improving the docs and
updating the build tooling.

## Breaking changes

In order to make some improvements we were forced to introduce a few breaking
changes.
**These were the result of real-world production testing and feedback**.
The community has evolved and we’ve come up with newer, better ideas over the
last year.
We have made sure the impact is small and have written a full migration guide.

* 🚨`@mdx-js/tag` is replaced by `@mdx-js/react` and an `@mdx` pragma
  — [migration guide](/migrating/v1#pragma)
* MDXProvider now merges component contexts when nested
  — [migration guide](/migrating/v1#mdxprovider)
* React support now requires `>= 16.8` in `@mdx-js/react`
  — [migration guide](/migrating/v1#react)

[Read the full v1 migration guide](/migrating/v1)

### Deprecations

We only needed to introduce one deprecation.
The `mdPlugins` and `hastPlugins` options have been renamed `remarkPlugins` and
`rehypePlugins` respectively.
For the time being we will issue a warning when the old options are used.
In v2, the old options will be removed.

## 📈 Growth

A major release is always a good time to take a step back and reflect on what’s
been happening in terms of growth and the greater community.
The ecosystem surrounding MDX has already grown larger than we ever dreamed.
We’ve also seen projects/products/application we never even imagined.

### Numbers

* **Downloads**: 125,000/week, 2.4M total
* **Stars**: 6,200
* **Contributors**: 50
* **Pull requests**: 281
* **Commits**: 670

The contributor growth is one of the most important aspects here as we have
numerous community members that are familiar with MDX internals.
This allows us to continually improve the project and spread the workload
against an ever growing team of contributors.

[See the contributor graph](https://github.com/mdx-js/mdx/graphs/contributors?from=2017-12-17\&to=2019-04-11\&type=c)

### Ecosystem

* [Prettier](https://prettier.io)
* [Docz](https://github.com/pedronauck/docz)
* [MDX Deck](https://github.com/jxnblk/mdx-deck)
* [Next.js](https://nextjs.org)
* [Gatsby][gatsbyjs]
* [AST Explorer](https://astexplorer.net)
* [Vue support (alpha)](/docs/getting-started/#vue)
* [Demoboard](https://frontarm.com/demoboard/)
* [Editors](/docs/getting-started/#editor)

## 🛣 Roadmap

With v1 released we have a roadmap in place that we’ll continue working towards
over the next 6 months or so in addition to bug fixes and parsing issues we
might encounter.

* MDXs: [#454](https://github.com/mdx-js/mdx/issues/454)
* Interleaving: [#195](https://github.com/mdx-js/mdx/issues/195)
* Global shortcodes: [#508](https://github.com/mdx-js/mdx/pull/508)
* Stable Vue support: [#238](https://github.com/mdx-js/mdx/issues/238)
* Blocks: MDX WYSIWYG: [blocks/blocks][blocks]
* MDX playground inspired by AST Explorer: [#220](https://github.com/mdx-js/mdx/issues/220)
* New splash page: [#444](https://github.com/mdx-js/mdx/issues/444)
* Showcase page: [#414](https://github.com/mdx-js/mdx/issues/414)

### Vue support

Supporting Vue is an important goal for MDX and is one of the primary reasons
we’ve rearchitected MDX to use custom pragma.
We’re delighted that **we now have an alpha version for Vue working**.
We’d love it if anyone from the Vue community wants to give it a try and provide
feedback.

[See the Vue example](https://github.com/mdx-js/mdx/tree/36cb41b/examples/vue)

### Blocks project

One of the key missing aspects of authoring MDX documents is the editing
experience.
Currently, there isn’t an approachable way to write MDX unless you enjoy working
in a text editor and writing raw Markdown/code.
We’d like to solve that and have begun work on an MDX “blocks editor” that’s a
**content-focused WYSIWYG**.
Not to mention, we’ll be doing all that we can to make sure the editor is as
accessible as it can be from the beginning.

When we have a beta ready we will be open sourcing it and announcing, so stay
tuned.

[Check out the Blocks project][blocks]

## unified collective

MDX is part of the unified collective, which is an open source ecosystem for
dealing with many sources of content.
unified projects are used all over the web, and it would never be possible
without financial support from our fine sponsors.

* [ZEIT][] 🥇
* [Gatsby][gatsbyjs] 🥇
* [Holloway](https://www.holloway.com) 🥉
* [Backers](https://opencollective.com/unified#budget) 🏆
* [You?](https://opencollective.com/unified)👤

## 🙏 Thanks

We’d like to say thanks to all our contributors and our happy users.
Special thanks to
[@wooorm][wooorm],
[@silvenon](https://github.com/silvenon),
[@timneutkens](https://github.com/timneutkens),
[@ChristopherBiscardi][christopherbiscardi],
[@jxnblk](https://github.com/jxnblk),
[@alexandernanberg](https://github.com/alexandernanberg),
[@jescalan](https://github.com/jescalan),
[@Jarred-Sumner](https://github.com/Jarred-Sumner),
[@leimonio](https://github.com/leimonio),
[@ticky](https://github.com/ticky),
[@jamesknelson](https://github.com/jamesknelson),
[@pshrmn](https://github.com/pshrmn),
[@rauchg](https://github.com/rauchg),
[@joelhooks](https://github.com/joelhooks),
[@jlengstorf](https://github.com/jlengstorf),
[@johnlindquist](https://github.com/johnlindquist),
[@kyleamathews](https://github.com/kyleamathews),
[@kentcdodds](https://github.com/kentcdodds),
[@wesbos](https://github.com/wesbos),
[@rosew](https://github.com/rosew),
[@pedronauck](https://github.com/pedronauck),
[@tayiorbeii](https://github.com/tayiorbeii),
[@nickbender](https://github.com/nickbender),
[@ntaylor89](https://github.com/ntaylor89),
[@mxstbr](https://github.com/mxstbr),
[@manovotny](https://github.com/manovotny),
[@xyc](https://github.com/xyc),
[@filoxo](https://github.com/filoxo),
[@millette](https://github.com/millette),
[@hugmanrique](https://github.com/hugmanrique),
[@johnsherrard](https://github.com/johnsherrard),
[@sw-yx](https://github.com/sw-yx),
and anyone we may have forgotten.

[blocks]: https://github.com/blocks/blocks

[christopherbiscardi]: https://github.com/christopherbiscardi

[gatsbyjs]: https://gatsbyjs.org

[wooorm]: https://github.com/wooorm

[zeit]: https://zeit.co

---

## File: docs/blog/v2.mdx

import {Note} from '../_component/note.jsx'
export const info = {
  author: [
    {github: 'wooorm', name: 'Titus Wormer'}
  ],
  modified: new Date('2025-01-27'),
  published: new Date('2022-02-01')
}

<Note type="legacy">
  **Note**: This is an old blog post.
  The below is kept as is for historical purposes.
</Note>

<Note type="info">
  **Note**: Info on how to migrate is available in our
  [Version 2 migration guide][migrating].
</Note>

# MDX 2

Version 2 of MDX was released after years of hard work, and has many
improvements.
Here are the highlights:

{/* more */}


  * 📝 **Improved syntax** makes it easier to use markdown in JSX
  * 🧑‍💻 **JavaScript expressions** turn `{2 * Math.PI}` into {2 * Math.PI}
  * 🔌 New **esbuild**, **Rollup**, and **Node.js** integrations
  * ⚛️ **Any JSX runtime**: React, Preact, Vue, Emotion, you name it, they’re
    all supported
  * 🌳 **Improved AST** exposes more info in greater detail
  * 🏃‍♀️ Compiles at least **25% faster**
  * 🚴 Generated code runs twice as fast (**100% faster**)
  * 🚄 Bundle size of `@mdx-js/mdx` is more than three times as small
    (**250% smaller**)
  * 🧵 …and much, so much more


It’s been 4 years since this project was announced.
2½ since we released our stable version 1.
**We’re proud to finally release v2!**
Let’s dive in!

## Contents

* [Improvements to the MDX format](#improvements-to-the-mdx-format)
* [Rollup, esbuild, and other integrations](#rollup-esbuild-and-other-integrations)
* [Architectural improvements](#architectural-improvements)
* [TypeScript](#typescript)
* [Docs & site](#docs--site)
* [Breaking changes](#breaking-changes)
* [Thanks](#thanks)

## Improvements to the MDX format

We’ve spent a lot of time thinking and trying out different ways to improve the
format.
Originally, the format was very close to how markdown, and HTML in markdown,
works.
We found that the old behavior often yielded unexpected results.
In version 2, we shift the format a little bit closer to how JS(X) works.

Take for example this MDX file:

```mdx chrome=no
*hi*?


  # hi?


<main>
  

    # hi?

  
</main>
```


  
    In version 1, that was equivalent to the following JSX:

    ```tsx chrome=no
    <>
      *hi*?
      
        # hi?
      
      <main>
        
          `# hi?`
        
      </main>
    </>
    ```
  

  
    In version 2, it’s equivalent to the following JSX:

    ```tsx chrome=no
    <>
      *hi*?
      
        <h1>hi?</h1>
      
      <main>
        
          <h1>hi?</h1>
        
      </main>
    </>
    ```
  


We believe it’s more intuitive that markdown “inlines” such as emphasis can form
between tags on the same line (first ``), “blocks” such as headings can
form if they’re on their own line (second ``), and indentation is allowed
rather than forming code (third ``).

We also added support for JavaScript expressions, take for example:


  
    ```mdx path="expressions.mdx"
    export const authors = [
      {name: 'Jane', email: 'hi@jane.com'},
      {name: 'John', github: '@johno'}
    ]
    export const published = new Date('2022-02-01')

    Written by: {new Intl.ListFormat('en').format(authors.map(d => d.name))}.

    Published on: {new Intl.DateTimeFormat('en', {dateStyle: 'long'}).format(published)}.
    ```
  

  
    ```tsx path="equivalent.jsx"
    <>
      Written by: Jane and John.
      Published on: February 1, 2022.
    </>
    ```
  


As the format moves a little further from markdown towards JSX, we’ve added
support for loading “normal” markdown without our syntax extensions.
If you’re using our bundler integration `@mdx-js/loader` (or `@mdx-js/rollup`,
`@mdx-js/esbuild`, or `@mdx-js/node-loader`, see next section), then that’ll
just work: import `readme.mdx` and it’s seen as the MDX format, import
`readme.md` and it’s seen as markdown, based on their extensions.

The MDX format is described in [§ What is MDX?][what]

## Rollup, esbuild, and other integrations

When we started out, Babel, webpack, and React were ubiquitous in the JavaScript
ecosystem and we built MDX on them.
For version 2, we worked hard to make them optional.
They’re no longer required and MDX can more easily be used with other tools.

On the bundler side, we’ve added new integrations: `@mdx-js/esbuild` for
esbuild (an extremely fast bundler) and `@mdx-js/rollup` for Rollup (a bundler
that’s also used in Vite and WMR).
You can even import MDX files directly in Node.js with our new
`@mdx-js/node-loader`.

On the runtime side, we can now compile JSX away to normal JavaScript and
no longer need framework-specific code to glue them together with MDX.
Now any JSX runtime, whether [classic or automatic][jsx-runtime], is supported.
This means MDX can be used with React, Preact, Vue, Emotion, Theme UI, Ink, you
name it, plus anything that’s yet to be invented!

See [§ Getting started][getting-started] for a quick start but also in-depth
info on how to integrate MDX with many different tools.

## Architectural improvements

To make the syntax of the MDX format better and to allow new integrations and
arbitrary JSX runtimes, we’ve rewritten almost everything.
Part of that effort was [micromark][], which is another story, but it means
we’re fully CommonMark (and optionally GFM) compliant, while also understanding
more about MDX files.

Now we can throw an early error when there’s a typo and point to exactly where
it happened, instead of a later bundler like webpack complaining about an error
in an intermediate, unrecognizable, and broken string of JavaScript.
It also means that we have a new AST which describes the MDX syntax in more
detail — we even expose the embedded JavaScript.
This detailed AST allows plugins to enhance MDX in powerful new ways.
It also helped solve edge cases where MDX would previously crash.
And it let us drop Babel.

This new architecture results in **25% faster** compilation, generated code
that runs twice as fast (**100% faster**), and that the bundle size of
`@mdx-js/mdx` is more than three times as small (**250% smaller**).

See [¶ Architecture in `@mdx-js/mdx`][architecture] for more on how our compiler
works.
See [§ Extending MDX][extending] for several plugins that use the new tree to
enhance MDX, how to use them and other plugins, and how to create plugins.

## TypeScript

All [`@mdx-js/*` packages][packages] are now fully typed with [TypeScript][]
through JSDoc comments.
That means our APIs are exposed as TypeScript types but also that our projects
are type safe internally.

We’ve published [`@types/mdx`][types-mdx], a types-only package that can be used
with any (community) integration.
You can use it, if you’re importing MDX files, to type those imported
components.

See [¶ TypeScript in § Getting started][ts] for more on how to use configure
TypeScript.

## Docs & site

MDX is used and liked a lot.
Before version 1 we had amassed a total of **2.5m downloads**.
Now we hit that number every week.
Our core compiler `@mdx-js/mdx` is used in **61k projects**.
Our GitHub repo has **11.6k stars**.

Many people help, often with docs.
85 contributors committed to our repo since version 1.
We’re grateful for these contributions and all those individual insights,
but over the years it did result in some inconsistencies and duplicated content.

For version 2, we rewrote our docs from beginning to end to tell a consistent
story for new users, folks that do complex AST and compiler stuff, and
anyone in between.

We also made a new website.
It’s built on MDX of course, [unified][] itself, and [React Server Components
(RSC)][rsc].
While we dogfood the former two as they’re projects we maintain, and the
latter is extremely experimental, we think compiling things ahead of time and
betting on hybrid models, compared to completely server-side sites or completely
client-side apps, is the smart choice for us and the web’s future.

Our new site is heavily optimized and fast, gorgeous (subjective but hey), has
rich metadata, and scores very well in performance and accessibility review
tools such as Lighthouse and axe.

See [§ Contribute][contribute] for more on how to help.

## Breaking changes

When you’re ready to migrate, please see the
[Version 2 migration guide][migrating].

## Thanks

We’d like to say thanks to all our contributors and our happy users.
Special thanks to
John Otander ([**@johno**](https://github.com/johno)),
Christian Murphy ([**@ChristianMurphy**](https://github.com/ChristianMurphy)),
JounQin ([**@JounQin**](https://github.com/JounQin)),
Jack Bates ([**@jablko**](https://github.com/jablko)),
Sam Chen ([**@chenxsan**](https://github.com/chenxsan)),
Sam Robbins ([**@samrobbins85**](https://github.com/samrobbins85)),
Remco Haszing ([**@remcohaszing**](https://github.com/remcohaszing)),
LB ([**@laurieontech**](https://github.com/laurieontech)),
Gabriel Kirkley ([**@gdgkirkley**](https://github.com/gdgkirkley)>),
Hung-I Wang ([**@Gowee**](https://github.com/Gowee)),
Ilham Wahabi ([**@iwgx**](https://github.com/iwgx)),
Kaito Sugimoto ([**@HelloRusk**](https://github.com/HelloRusk)),
Karl Horky ([**@karlhorky**](https://github.com/karlhorky)),
Katie Hughes ([**@glitteringkatie**](https://github.com/glitteringkatie)),
Lachlan Campbell ([**@lachlanjc**](https://github.com/lachlanjc)),
Marcy Sutton ([**@marcysutton**](https://github.com/marcysutton)),
Marius Gundersen ([**@mariusGundersen**](https://github.com/mariusGundersen)),
Marius-Remus Mate,
Mark Skelton ([**@mskelton**](https://github.com/mskelton)),
Martin V ([**@ndresx**](https://github.com/ndresx)),
Matija Marohnić ([**@silvenon**](https://github.com/silvenon)),
Michael Oliver ([**@michaeloliverx**](https://github.com/michaeloliverx)),
Michaël De Boey ([**@MichaelDeBoey**](https://github.com/MichaelDeBoey)),
Muescha ([**@muescha**](https://github.com/muescha)),
Norviah ([**@Norviah**](https://github.com/Norviah)),
Paul Scanlon ([**@PaulieScanlon**](https://github.com/PaulieScanlon)),
Peter Mouland ([**@peter-mouland**](https://github.com/peter-mouland)),
Prince Wilson ([**@maxcell**](https://github.com/maxcell)),
Rafael Almeida ([**@rafaelalmeidatk**](https://github.com/rafaelalmeidatk)),
Rodrez ([**@rodrez**](https://github.com/rodrez)),
Rongjian Zhang ([**@pd4d10**](https://github.com/pd4d10)),
Taeheon Kim ([**@lonyele**](https://github.com/lonyele)),
Tom Parker-Shemilt ([**@palfrey**](https://github.com/palfrey)),
Try Ajitiono ([**@imballinst**](https://github.com/imballinst)),
Yamagishi Kazutoshi ([**@ykzts**](https://github.com/ykzts)),
Yoav Kadosh ([**@ykadosh**](https://github.com/ykadosh)),
Yordis Prieto ([**@Yordis**](https://github.com/Yordis)),
Adrian Foong ([**@adrfoong**](https://github.com/adrfoong)),
Dan Abramov ([**@gaearon**](https://github.com/gaearon)),
[**@ihupoo**](https://github.com/ihupoo),
[**@nikhog**](https://github.com/nikhog),
[**@redallen**](https://github.com/redallen),
Akshay Kadam ([**@deadcoder0904**](https://github.com/deadcoder0904)),
я котик пур-пур ([**@mvasilkov**](https://github.com/mvasilkov)),
Anders D. Johnson ([**@AndersDJohnson**](https://github.com/AndersDJohnson)),
Andrew Aylett ([**@andrewaylett**](https://github.com/andrewaylett)),
Ankeet Maini ([**@ankeetmaini**](https://github.com/ankeetmaini)),
Biswas Nandamuri ([**@Biswas-N**](https://github.com/Biswas-N)),
Bret ([**@bcomnes**](https://github.com/bcomnes)),
Chris Chinchilla ([**@ChrisChinchilla**](https://github.com/ChrisChinchilla)),
Christopher Biscardi ([**@ChristopherBiscardi**](https://github.com/ChristopherBiscardi)),
Dan Overton ([**@dan-overton**](https://github.com/dan-overton)),
Domitrius ([**@domitriusclark**](https://github.com/domitriusclark)),
Dovi Winberger ([**@dowi**](https://github.com/dowi)),
Emmie Päivärinta ([**@emmiep**](https://github.com/emmiep)),
Eugene Ghanizadeh ([**@loreanvictor**](https://github.com/loreanvictor)),
and anyone we may have forgotten.

[architecture]: /packages/mdx/#architecture

[contribute]: /community/contribute/

[extending]: /docs/extending-mdx/

[getting-started]: /docs/getting-started/

[jsx-runtime]: https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html

[micromark]: https://github.com/micromark/micromark

[migrating]: /migrating/v2/

[packages]: /packages/

[rsc]: https://reactjs.org/blog/2020/12/21/data-fetching-with-react-server-components.html

[ts]: /docs/getting-started/#types

[types-mdx]: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/mdx

[typescript]: https://www.typescriptlang.org

[unified]: https://unifiedjs.com

[what]: /docs/what-is-mdx/

---

## File: docs/blog/v3.mdx

import {Note} from '../_component/note.jsx'
export const info = {
  author: [
    {github: 'wooorm', name: 'Titus Wormer'}
  ],
  modified: new Date('2025-01-27'),
  published: new Date('2023-10-24')
}

<Note type="info">
  **Note**: Info on how to migrate is available in our
  [Version 3 migration guide][migrating].
</Note>

# MDX 3

Version 3 already!
This major version contains a couple small changes.
For most folks, updating Node.js and plugins is all that’s needed!

{/* more */}

## Contents

* [Breaking changes](#breaking-changes)
* [Improvements to the MDX format](#improvements-to-the-mdx-format)
  * [Adjacent block JSX and expressions in MDX](#adjacent-block-jsx-and-expressions-in-mdx)
  * [Await in MDX](#await-in-mdx)
  * [ES2024 in MDX](#es2024-in-mdx)
* [Miscellaneous](#miscellaneous)
* [Thanks](#thanks)

## Breaking changes

The main breaking change is that Node.js 16 is now the minimum supported
version.

Across the ecosystem there were several small internal breaking changes.
Everything’s released already.
You can update all plugins now.
If you ran into problems before, it should work now.

We also removed some infrequently used deprecated APIs.
You’re likely fine but gloss over the [v3 migration guide][migrating] if you
get errors.

Important to note when you use your lesser-known but powerful `evaluate`, `run`,
or `outputFormat: 'function-body'` APIs, please pass the `baseUrl` option.
That makes sure `import.meta.url`, `import`, and `export` work.
You’ll get a runtime error when those features are used otherwise.

## Improvements to the MDX format

There’s also a few small improvements to the MDX format, some of which
technically breaking.

### Adjacent block JSX and expressions in MDX

We now accept block expressions right next to block JSX tags:

```mdx chrome=no
<style>{`

  h1 {
    color: blue;
  }

`}</style>
```

Previously, there was a syntax error, and you had to add a newline between the
angle brackets and the braces.

### Await in MDX

We now accept `await` syntax:

```mdx
{await Promise.resolve(42)}
```

Most frameworks don’t support promises.
Whether this works depends on that.

Previously, there was a runtime error that `await` was used in a context where
it wasn’t allowed.

### ES2024 in MDX

You can now use modern JavaScript syntax in MDX.
Acorn, used internally, is now instructed to use ES2024.

## Miscellaneous

I refactored all the docs.
Updating every use example where needed.
I also wrote a guide on how to inject components from anywhere:
[§ Injecting components][injecting-components].

The site is a lot faster.
There’s a nice improved playground too: [try it out! »][playground].
We also have proper syntax highlighting here, thanks to
[`wooorm/markdown-tm-language`][markdown-tm-language]
and [`wooorm/starry-night`][starry-night].

The generated JS code is a little cleaner (the JSX pragma comment is removed
and objects are sorted where needed), it also uses spreads instead of
`Object.assign`, there’s a `'use strict'` added when needed, and the
`MDXContent` is exported immediately.

## Thanks

We’d like to say thanks to all our contributors and our happy users.
Special thanks to
北雁云依 ([**@BeiyanYunyi**](https://github.com/BeiyanYunyi)),
Christian Murphy ([**@ChristianMurphy**](https://github.com/ChristianMurphy)),
JokcyLou ([**@Jokcy**](https://github.com/Jokcy)),
Maël Nison ([**@arcanis**](https://github.com/arcanis)),
Andreas Deininger ([**@deining**](https://github.com/deining)),
Remco Haszing ([**@remcohaszing**](https://github.com/remcohaszing)),
Sébastien Lorber ([**@slorber**](https://github.com/slorber)),
Víctor Fernández ([**@victor23k**](https://github.com/victor23k)),
Titus Wormer ([**@wooorm**](https://github.com/wooorm)),
and anyone we may have forgotten.

[injecting-components]: /guides/injecting-components/

[markdown-tm-language]: https://github.com/wooorm/markdown-tm-language

[migrating]: /migrating/v3/

[playground]: /playground/

[starry-night]: https://github.com/wooorm/starry-night

---

## File: docs/community/about.mdx

import {Note} from '../_component/note.jsx'

export const info = {
  author: [
    {github: 'wooorm', name: 'Titus Wormer'}
  ],
  modified: new Date('2025-01-27'),
  published: new Date('2021-10-06')
}
export const navSortSelf = 4

# About

This article explains in short how MDX came to be and why it exists.
It also gives thanks to the people who’ve helped make it and inspired it.

{/* more */}

## What is MDX?

MDX is the combination of markdown with JSX.
See [§ What is MDX?][what] for more info.

## Why MDX?

Markdown does not have a syntax for custom components.
MDX solves this.

There are many languages objectively better than markdown, however, markdown is
great because:

* It looks like what it means and is relatively easy to read
* Although images are [confusing][], most stuff is relatively simple to write
* It’s loose and ambiguous: it may not work but you won’t get an error (great
  for someone posting a comment to a forum if they forgot an asterisk)

Markdown *does* have a way to extend it, HTML, but that has drawbacks:

* HTML in markdown is naïve, how it’s parsed sometimes doesn’t make sense
* HTML is unsafe by default, so it’s sometimes (partially) unsupported
* HTML and markdown don’t mix well, resulting in confusing rules such as
  blank lines or `markdown="1"` attributes
* HTML is coupled with browsers, markdown is useful for other things too

The frontend world has an alternative to HTML: JSX.
JSX is great, amongst other things, because:

* It has a relatively familiar syntax (like XML)
* It’s agnostic to semantics and intended for compilers (can have any
  domain-specific meaning)
* It’s strict and unambiguous (great if an author forgot a slash somewhere, as
  they’ll get an error early, instead of a book going to print with broken
  stuff in it)

## Who governs MDX?

The project is governed by the
[unified collective][governance].

## Who created MDX?

The idea of combining [markdown][commonmark], [JavaScript][], and [JSX][] was a
collaborative effort by
[Guillermo Rauch][mdx-rauchg] (**[@rauchg][rauchg]**),
[James K. Nelson][mdx-jamesknelson] (**[@jamesknelson][jamesknelson]**),
[John Otander][mdx-johno] (**[@johno][johno]**),
Tim Neutkens (**[@timneutkens][timneutkens]**),
Brent Jackson (**[@jxnblk][jxnblk]**),
Jessica Stokes (**[@ticky][ticky]**), and more.

While everyone above was key to MDX, we want to stress the involvement of
[John Otander][mdx-johno] (**[@johno][johno]**).
John wrote most of the code for the first alpha and later stable version 1 of
this project!

## Who designed the logo?

[Logo designs][design] were created by [Evil Rabbit][] of [Vercel][].

## What projects inspired MDX?

The following projects, languages, and articles helped shape MDX either in
implementation or inspiration.

The [markdown][] and [JSX][] languages inspired MDX.
Markdown was [created by John Gruber][markdown] (**[@gruber][gruber]**).
[CommonMark][], the most popular markdown variant, by John McFarlane
(**[@jgm][jgm]**) et al.
JSX was created by Sebastian Markbåge (**[@sebmarkbage][sebmarkbage]**) et
al. at Facebook, Inc.

The `@mdx-js/*` projects currently make heavy use of [unified][] (specifically
[micromark][], [remark][] and [rehype][]) and [Acorn][].
unified, remark, rehype, and related tools were created by Titus Wormer
(**[@wooorm][wooorm]**) et al.
Acorn by Marijn Haverbeke (**[@marijnh][marijnh]**) et al.

The following projects inspired `@mdx-js/*` originally:

{/* Note: please keep the original project names intact: */}

* [`jamesknelson/mdxc`](https://github.com/frontarm/mdx-util)
* [`ticky/markdown-component-loader`](https://github.com/ticky/markdown-component-loader)
* [`threepointone/markdown-in-js`](https://github.com/threepointone/markdown-in-js)
* [`fazouane-marouane/remark-jsx`](https://github.com/remarkjs/remark-jsx)
* [`mapbox/remark-react`](https://github.com/remarkjs/remark-react)
* [`rx-ts/eslint-mdx`](https://github.com/mdx-js/eslint-mdx)

The following articles inspired `@mdx-js/*` originally:

* [IA Markdown Content Blocks](https://github.com/iainc/Markdown-Content-Blocks)
* [Idyll: Markup language for interactive documents](https://idyll-lang.org)

[acorn]: https://github.com/acornjs/acorn

[commonmark]: https://spec.commonmark.org/current/

[confusing]: https://twitter.com/gruber/status/1246489863932821512

[design]: https://github.com/mdx-js/design

[evil rabbit]: https://evilrabb.it

[governance]: https://github.com/unifiedjs/collective

[gruber]: https://github.com/gruber

[jamesknelson]: https://github.com/jamesknelson

[javascript]: https://tc39.es/ecma262/

[jgm]: https://github.com/jgm

[johno]: https://github.com/johno

[jsx]: https://facebook.github.io/jsx/

[jxnblk]: https://github.com/jxnblk

[marijnh]: https://github.com/marijnh

[markdown]: https://daringfireball.net/2004/03/introducing_markdown

[mdx-jamesknelson]: https://github.com/frontarm/mdx-util/tree/0f5f6d62bac4b83edc4bc3890dde3011079fa318

[mdx-johno]: https://github.com/mdx-js/mdx/tree/a96ede2c104084ae21efa8bd95319011e558ec9d

[mdx-rauchg]: https://spectrum.chat/frontend/general/mdx-proposal~1021be59-2738-4511-aceb-c66921050b9a

[micromark]: https://github.com/micromark/micromark

[rauchg]: https://github.com/rauchg

[rehype]: https://github.com/rehypejs/rehype

[remark]: https://github.com/remarkjs/remark

[sebmarkbage]: https://github.com/sebmarkbage

[ticky]: https://github.com/ticky

[timneutkens]: https://github.com/timneutkens

[unified]: https://unifiedjs.com

[vercel]: https://vercel.com

[what]: /docs/what-is-mdx/

[wooorm]: https://github.com/wooorm

---

## File: docs/community/contribute.mdx

import {Note} from '../_component/note.jsx'

export const info = {
  author: [
    {github: 'wooorm', name: 'Titus Wormer'}
  ],
  modified: new Date('2025-01-27'),
  published: new Date('2018-11-04')
}
export const navSortSelf = 2

# Contribute

This article explains how to contribute to MDX.
Please read through the following guidelines.

{/* more */}

<Note type="important">
  **Important**: before participating in our community, please read our
  [code of conduct][coc].
  By interacting with this repository, organization, or community you agree to
  abide by its terms.
</Note>

## Contributions

There’s several ways to contribute, not just by writing code.
If you have questions, see [§ Support][support].
If you can provide financial support, see [§ Sponsor][sponsor].

### Improve docs

As a user you’re perfect for helping us improve our docs.
Typo corrections, error fixes, better explanations, new examples, etcetera.
All MDX docs live in `docs/`.

You can run the docs locally, see [¶ Site][site] below.

### Improve issues

Some issues lack information, aren’t reproducible, or are just incorrect.
You can help by trying to make them easier to resolve.
Existing issues might benefit from your unique experience or opinions.

### Write code

Code contributions are very welcome.
It’s probably a good idea to first post a question or open an issue to report a
bug or suggest a new feature before creating a pull request.

## Submitting an issue

* The issue tracker is for issues.
  Use discussions for support
* Search the issue tracker (including closed issues) before opening a new
  issue
* Ensure you’re using the latest version of our packages
* Use a clear and descriptive title
* Include as much information as possible: steps to reproduce the issue,
  error message, version, operating system, etcetera
* The more time you put into an issue, the better we will be able to help you
* The best issue report is a failing test proving it

## Submitting a pull request

* See [¶ Project][project] below for info on how the project is structured,
  how to test, and how to build the site
* Non-trivial changes are often best discussed in an issue first, to prevent
  you from doing unnecessary work
* For ambitious tasks, you should try to get your work in front of the
  community for feedback as soon as possible
* New features should be accompanied by tests and documentation
* Don’t include unrelated changes
* Test before submitting code by running `npm test`
* Write a convincing description of why we should land your pull request:
  it’s your job to convince us

## Project

### Structure

MDX is a monorepo.
All packages are in `packages/`.
Documentation is in `docs/`.

### Tests

To run the tests, first do `npm install`, then do `npm test`.
This ensures everything is okay, from code style to unit tests to types.

### Site

To build the site, first do `npm install`, then do `npm run docs`.
This produces the website in `public/`.

### Release

To release a new version, do:

1. update `version`s of packages with a patch, minor, or major (make sure to
   update dependency ranges on monorepo packages when needed):
   ```sh
   npm version minor --workspaces --no-git-tag-version
   ```
2. commit and tag using the version (without `v`) as the message:
   ```sh
   git commit --all --message 1.2.3 && git tag 1.2.3 && git push && git push --tags
   ```
3. release to the npm registry:
   ```sh
   npm publish --workspaces
   ```
4. add a changelog entry for the release on GitHub:
   ```sh
   open https://github.com/mdx-js/mdx/releases
   ```

## Resources

* [Good first issues in the MDX repository](https://github.com/mdx-js/mdx/labels/good%20first%20issue%20👋)
* [How to contribute to open source](https://opensource.guide/how-to-contribute/)
* [Making your first contribution](https://medium.com/@vadimdemedes/making-your-first-contribution-de6576ddb190)
* [Using pull requests](https://help.github.com/articles/about-pull-requests/)
* [GitHub help](https://help.github.com)

[coc]: https://github.com/mdx-js/.github/blob/main/code-of-conduct.md

[project]: #project

[site]: #site

[sponsor]: /community/sponsor/

[support]: /community/support/