File conventions

App Router MDX component mapping

With @next/mdx in the App Router, place mdx-components.tsx alongside app or in the corresponding src root. Export useMDXComponents to provide element overrides. Install and configure compatible MDX dependencies separately. Only compile trusted, reviewed MDX because expressions and imports can execute code. Source: https://nextjs.org/docs/app/api-reference/file-conventions/mdx-components. Documentation-reviewed illustrative draft; installed declarations and runtime not verified.

Formal Syntax & Structure

nextjs syntaxnextjs
mdx-components.tsx; useMDXComponents()

Working Example

Example Snippetnextjs
import type { MDXComponents } from 'mdx/types'; export function useMDXComponents(): MDXComponents {return {h2: ({children}) => <h2 className="section-title">{children}</h2>}}
Next.js Reference