Document and develop React components with MDX and Next.js
npm init docs
To create a new documentation site, run npm init docs
and follow the prompts.
Once the application has been generated, see the README.md
for more documentation.
To add MDX Docs to an existing Next.js app, see the Custom Setup docs.
MDX lets you mix markdown with inline JSX to render React components. Write markdown as you normally would and use ES import syntax to use custom components in your document.
import { Box } from 'grid-styled'
# Hello MDX!
<Box
p={3}
bg='tomato'>
This will render as a component
</Box>
MDX Docs has built-in components to render JSX fenced code blocks as live previews with editable code, powered by react-live.
To make a code block render as an editable example, use the .jsx
language attribute (note the .
prefix).
Live code example:
```.jsx
<button>Beep</button>
```
Below is a rendered example of using a live code fence:
<button>Beep</button>