Skip to content
This page is also available as Markdown at /docs/app/api-reference/file-conventions/mdx-components.md. For an index of Next.js documentation, see /docs/llms.txt.

mdx-components.js

Last updated July 29, 2025

The mdx-components.js|tsx file is required to use @next/mdx with App Router and will not work without it. Additionally, you can use it to customize styles.

Use the file mdx-components.tsx (or .js) in the root of your project to define MDX Components. For example, at the same level as pages or app, or inside src if applicable.

mdx-components.tsx
import type { MDXComponents } from 'mdx/types'
 
const components: MDXComponents = {}
 
export function useMDXComponents(): MDXComponents {
  return components
}

Exports

useMDXComponents function

The file must export a single function named useMDXComponents. This function does not accept any arguments.

mdx-components.tsx
import type { MDXComponents } from 'mdx/types'
 
const components: MDXComponents = {}
 
export function useMDXComponents(): MDXComponents {
  return components
}

Version History

VersionChanges
v13.1.2MDX Components added

Was this helpful?