Using MDX for Documentation

MDX is a tool that lets you write React code directly in Markdown. This page is written in Markdown, but if needed, we can include React components and JavaScript directly in our Markdown. Below is a Counter component that is defined within the Markdown and then called in the Markdown.

You clicked 0 times

This page you are viewing was written in Markdown, but the functionality above was made possible by including React code.

MDX Files

Once you set up MDX to run in your project, the only step needed to use MDX is to create a file with the extension .mdx. If you name a file about.mdx, you'll be able to access it from https://example.com/about.

You can view this page on GitHub to see the React component in use.