TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/shuding/nextra/llms.txt
Use this file to discover all available pages before exploring further.
page.mdx (and page.md) file is Nextra’s integration point with the Next.js App Router. When you place an MDX file named page.mdx inside a folder under app/, Next.js treats it just like any other page file — but Nextra’s webpack loader processes the MDX content, adds syntax highlighting, parses front matter, and makes the page part of the site-wide pageMap.
What is a page File?
A page file is a Next.js App Router convention that defines the UI rendered for a specific route. By default Next.js supports .js, .jsx, and .tsx extensions. Nextra extends this with .md and .mdx so you can author content directly as Markdown.
Directory Structure
Placepage.mdx files anywhere inside your app/ directory, just as you would a regular page.tsx:
Comparing content/ vs app/ Approach
Both approaches produce the same rendered output, but they have different trade-offs:
- content/ directory
- app/ directory (page.mdx)
Files live in Best for: Large documentation sites, easy migration from the
content/, not in app/. A single catch-all route ([[...mdxPath]]/page.jsx) handles all content rendering.pages/ router, content that changes frequently.You can combine both approaches in the same project. Nextra collects
page.mdx files from app/ and .mdx files from content/ together into a unified pageMap.How Nextra Processes page.mdx
Nextra registers a webpack loader that intercepts .md and .mdx files loaded as Next.js pages. The loader:
- Parses YAML front matter from the file.
- Compiles MDX to JavaScript (using
@mdx-js/mdx). - Applies syntax highlighting via
rehype-pretty-code. - Injects a
metadataexport that Next.js uses for<head>tags (title,description, Open Graph, etc.). - Adds the page to the
pageMapthat powers the sidebar and navbar.
Front Matter Fields
Nextra reads YAML front matter at the top of everypage.mdx file. The following fields have special meaning:
| Field | Type | Description |
|---|---|---|
title | string | Page title — used in the <title> tag and sidebar |
description | string | Page description for the <meta name="description"> tag |
sidebarTitle | string | Shorter title shown in the sidebar when it differs from title |
icon | string | Icon name displayed next to the page in the sidebar |
asIndexPage | boolean | Marks a folder’s index.mdx as a clickable folder index |
app/docs/getting-started/page.mdx
The $NextraMetadata Type
Every compiled Nextra page exports a metadata object that extends the Next.js Metadata type. Its TypeScript shape is:
metadata export in a layout or theme to display reading time, a last-updated badge, or breadcrumbs:
app/docs/layout.tsx
Enable estimated reading time by setting
readingTime: true in your nextra() configuration inside next.config.mjs. The timestamp field is populated when your Nextra theme has timestamp rendering enabled.Enabling Reading Time
next.config.mjs
.md and .mdx file will include a readingTime key computed by the reading-time package.