The Nextra Docs Theme (Documentation 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.
nextra-theme-docs) is a full-featured documentation layout that wraps your Next.js App Router application with a polished, accessible shell — including a top navigation bar, collapsible sidebar, floating table of contents, full-text search via Pagefind, dark mode, and edit-on-GitHub links. Configure everything through the <Layout> component’s props in your root app/layout.jsx.
What’s Included
The docs theme bundles a rich set of UI features out of the box:Top Navigation Bar
Logo, project link, chat link, and custom menu items rendered in a sticky navbar.
Full-Text Search
Pagefind-powered static search via the built-in
<Search /> component.Collapsible Sidebar
Auto-collapsing page tree with configurable default collapse level and toggle button.
Table of Contents
Floating TOC on the right side of the page, sticky on scroll, with a back-to-top link.
Dark Mode Toggle
Seamless light/dark/system switching powered by
next-themes.Edit on GitHub
Per-page “Edit this page” link derived from
docsRepositoryBase.Feedback Link
Inline feedback button that opens a pre-filled GitHub issue.
Previous / Next Pagination
Bottom-of-page navigation links to adjacent pages in the sidebar tree.
Last Updated Timestamp
Displays the most recent git commit date for each page.
i18n Locale Switcher
Dropdown for multi-language sites configured via Next.js
i18n.Installation
import nextra from 'nextra'
const withNextra = nextra({
defaultShowCopyCode: true
})
export default withNextra({
reactStrictMode: true
})
Create
app/layout.jsx and wrap your application with <Layout> from nextra-theme-docs. Pass pageMap from nextra/page-map so the sidebar and navigation are generated automatically:import { Layout, Navbar, Footer } from 'nextra-theme-docs'
import { getPageMap } from 'nextra/page-map'
import 'nextra-theme-docs/style.css'
export default async function RootLayout({ children }) {
const pageMap = await getPageMap()
return (
<html lang="en" suppressHydrationWarning>
<body>
<Layout
pageMap={pageMap}
docsRepositoryBase="https://github.com/your-org/your-repo/tree/main/docs"
navbar={<Navbar logo={<strong>My Docs</strong>} />}
footer={<Footer>MIT {new Date().getFullYear()} © Your Name.</Footer>}
>
{children}
</Layout>
</body>
</html>
)
}
Layout Component
The<Layout> component is the central configuration point for the docs theme. Every visual and behavioral option is controlled through its props.
Props Reference
pageMap
The page map list — the result of calling
getPageMap('/') from nextra/page-map. This drives the sidebar, navigation links, and breadcrumbs. You must pass this prop for the sidebar to render correctly.children
The page content rendered inside the layout. This is always the
{children} passed by Next.js to the root layout component.navbar
A rendered
<Navbar> component. Import Navbar from nextra-theme-docs, configure its props, and pass the element here. If omitted, no navbar is rendered.footer
A rendered
<Footer> component. Import Footer from nextra-theme-docs and pass the element here. Children of <Footer> render as the footer content (e.g. copyright text).banner
A rendered
<Banner> component displayed above the navbar. Import Banner from nextra/components. Useful for announcing new releases or important notices.docsRepositoryBase
The base URL of the documentation repository. Must start with
https://. Used to construct the “Edit this page” link and the feedback issue link for each page.For monorepos or subdirectory layouts, point this at the app/ folder directly:editLink
The content rendered inside the edit link at the bottom of each page. Set to
null to disable the edit link entirely.feedback
Configuration for the per-page feedback link. By default, it links to a pre-filled GitHub issue form.
| Field | Type | Default | Description |
|---|---|---|---|
content | ReactNode | 'Question? Give us feedback' | Label text for the feedback link. Set to null to hide it. |
labels | string | 'feedback' | GitHub issue labels applied to newly created feedback issues. |
link | string | Auto-generated | Custom URL for the feedback link. Overrides the default GitHub issue link. |
search
The search component rendered in the navbar. Defaults to the Pagefind-powered
<Search /> from nextra/components. Pass a custom component or null to disable search.darkMode
Show or hide the dark mode toggle button. When set to
false, the theme selector is removed from the UI but the nextThemes configuration still applies.nextThemes
Configuration passed directly to the
next-themes ThemeProvider. All fields are optional.| Field | Type | Default | Description |
|---|---|---|---|
attribute | 'class' | data-$“ | 'class' | HTML attribute modified to apply the theme. |
defaultTheme | string | 'system' | Default theme name. |
disableTransitionOnChange | boolean | true | Disable CSS transitions when switching themes. |
forcedTheme | string | — | Forces a specific theme, overriding user preference. |
storageKey | string | 'theme' | localStorage key used to persist the user’s theme choice. |
navigation
Show or hide the previous/next page navigation links at the bottom of each page. Pass
false to hide both, true to show both, or an object for granular control.sidebar
Controls the behavior and appearance of the left sidebar. All sub-fields are optional.
| Field | Type | Default | Description |
|---|---|---|---|
autoCollapse | boolean | — | When true, automatically collapse inactive folders above defaultMenuCollapseLevel. |
defaultMenuCollapseLevel | number (int ≥ 1) | 2 | Folder depth at which the sidebar is collapsed by default. Set to 1 to collapse all top-level folders, Infinity to expand everything. |
defaultOpen | boolean | true | Whether the sidebar is open by default. |
toggleButton | boolean | true | Show or hide the sidebar toggle button. |
toc
Controls the Table of Contents displayed on the right side of each page.
| Field | Type | Default | Description |
|---|---|---|---|
backToTop | ReactNode | 'Scroll to top' | Text for the back-to-top button at the bottom of the TOC. |
extraContent | ReactNode | — | Additional content rendered below the TOC items. |
float | boolean | true | When true, the TOC floats next to the content (sticky on scroll). When false, it appears inline in the sidebar. |
title | ReactNode | 'On This Page' | Title heading above the TOC item list. |
themeSwitch
Translatable labels for the theme switcher options. Useful for i18n sites.
| Field | Type | Default |
|---|---|---|
dark | string | 'Dark' |
light | string | 'Light' |
system | string | 'System' |
i18n
Options for the language dropdown rendered in the navbar. Each entry maps a Next.js locale code (from
i18n.locales in next.config.js) to a human-readable display name.lastUpdated
Component rendered to show the last-updated date at the bottom of each page. Must be a
<LastUpdated /> element — passing a plain string or <div> will throw a validation error. Use the locale prop to localize the date format.copyPageButton
Show or hide the “Copy page content” button. When enabled, users can copy the entire Markdown content of the current page to the clipboard.
Navbar Component
The<Navbar> component renders the sticky top navigation bar with a logo, project links, and optional custom items.
Navbar Props
The logo element displayed on the left side of the navbar.
Controls whether the logo is wrapped in a link. Pass
true (default) to link to /, a string URL to link elsewhere, or false to render the logo without a link.URL for the project icon button (top-right). Defaults to the Nextra GitHub repository.
Custom icon for the project link button. Defaults to a GitHub icon.
URL for a secondary icon button — typically a Discord, Slack, or social link.
Custom icon for the chat link button. Defaults to a Discord icon.
Extra content rendered after the last icon in the navbar — typically used for a
<Search /> component or locale switcher.Aligns the navigation icons to the specified side of the navbar.
Additional CSS class name applied to the
<nav> element.Navbar Examples
- Custom Logo
- GitLab Project Link
Footer Component
The<Footer> component renders a simple footer area. Pass children to provide copyright text, links, or other content.
All Named Exports
The following are all named exports available fromnextra-theme-docs:
Components
Components
| Export | Description |
|---|---|
Layout | Root layout component — wraps the entire page tree |
Navbar | Top navigation bar |
Footer | Page footer |
NotFoundPage | Pre-built 404 page component |
ThemeSwitch | Standalone dark/light/system mode selector |
LocaleSwitch | Locale dropdown for i18n sites |
LastUpdated | Displays the last git-commit timestamp for a page |
Hooks and Utilities
Hooks and Utilities
| Export | Description |
|---|---|
useThemeConfig | React hook — access the resolved theme configuration |
useConfig | React hook — access the current page config |
useMenu | React hook — read the current sidebar open/close state |
setMenu | Setter function — programmatically open or close the sidebar |
useMDXComponents | MDX component map hook — use in mdx-components.js |
useTheme | Re-exported from next-themes — access the active theme |
Link | Internal link component with active-state styling |
Usage example
Complete Layout Example
The following shows a real-world root layout combining the most common options:pageMap must be awaited inside an async Server Component. The getPageMap() function reads from the filesystem at build time, so it cannot be called inside a Client Component.