mdx
withMdxcn
Wrap your MDX components once with withMdxcn. Graphs keep working even when your docs framework replaces standard tags, and ordinary Markdown alerts, quotes, shell sessions and footnotes get drawn in a frame. GitHub still shows the plain Markdown.
install
If you installed all.json, you already have it. Installed on its own, it also brings in Callout, Quote and Terminal.
command
wire
import { withMdxcn } from "@/registry/default/mdx/mdx"import { GraphTimeline } from "@/registry/default/graph-timeline/graph-timeline"export function useMDXComponents(components) {return withMdxcn({ ...components, GraphTimeline })}
- Runs on the server. The file has no "use client"; the frames it swaps in are client components.
- Register the parents you use. Lists and tables inside them need no imports.
mdx-components.tsx
upgrades
Write Markdown that already looks right on GitHub. On your site, it renders as the frames below. The full list is on the grammar page.
page.mdx
The CLI copies files. Edit the source.
Less, but better.
pnpm dlx shadcn@latest add @mdxcn/mdx✓ 7 files written
Footnotes
SVG does not survive a README.
overrides
Most docs frameworks replace standard tags with their own components, like li with ListItem or table with Table. Graphs read their content by tag name, so a replaced li looks like an unknown component and the list comes out empty. withMdxcn labels each replacement so graphs still recognize the original tag. It also works with React Server Components, because the label is passed as a data-graph-host prop.
mdx-components.tsx
options
Every upgrade is on by default. Turn off any you'd rather style yourself.
options