Skip to main content

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.

The <Layout> component is the top-level wrapper for every nextra-theme-docs site. You pass it to your root app/layout.tsx file alongside a pageMap and any optional configuration props, and it orchestrates the entire documentation shell — sidebar, navbar, footer, search, TOC, theming, and navigation links — automatically.
<Layout> uses Zod to validate its props at runtime. Invalid prop values (for example a docsRepositoryBase that does not start with https://) will throw a descriptive error during development.

Import

import { Layout } from 'nextra-theme-docs'

Usage Example

import { Footer, Layout, Navbar } from 'nextra-theme-docs'
import { Banner, Head } from 'nextra/components'
import { getPageMap } from 'nextra/page-map'
import 'nextra-theme-docs/style.css'

const navbar = <Navbar logo={<b>My Docs</b>} />
const footer = <Footer>MIT 2024 © My Company</Footer>

export default async function RootLayout({ children }) {
  return (
    <html lang="en" dir="ltr" suppressHydrationWarning>
      <Head />
      <body>
        <Layout
          navbar={navbar}
          footer={footer}
          pageMap={await getPageMap()}
          docsRepositoryBase="https://github.com/my-org/my-docs"
          editLink="Edit this page on GitHub"
        >
          {children}
        </Layout>
      </body>
    </html>
  )
}

Props

Required props

children
ReactNode
required
The page content rendered inside the documentation shell. In the App Router this is the {children} slot automatically provided by Next.js to every layout.
pageMap
PageMapItem[]
required
The full page map of your documentation site. Always pass the result of the getPageMap() call from nextra/page-map. Nextra uses this to build the sidebar, navigation, and breadcrumb.
import { getPageMap } from 'nextra/page-map'
// inside an async Server Component:
const pageMap = await getPageMap()

navbar
ReactNode
A rendered <Navbar> component. Pass a pre-instantiated element so you can co-locate all navbar configuration in one place.
import { Navbar } from 'nextra-theme-docs'
const navbar = <Navbar logo={<b>Acme Docs</b>} projectLink="https://github.com/acme" />
// then: <Layout navbar={navbar} ... />
A rendered <Footer> component. The footer area already includes locale and theme switchers; pass children to the Footer component for copyright text or additional links.
banner
ReactNode
A rendered <Banner> component from nextra/components used for site-wide announcements displayed above the navbar. Omit this prop entirely if you do not need a banner.
import { Banner } from 'nextra/components'
const banner = <Banner storageKey="v3-release">Nextra v3 is out 🎉</Banner>
// then: <Layout banner={banner} ... />

docsRepositoryBase
string
default:"https://github.com/shuding/nextra"
Base URL of the documentation repository. Must begin with https://. Used to auto-generate the Edit this page link and the Feedback link that appears in the TOC panel.For a monorepo or non-root path, include the full tree path:
<Layout docsRepositoryBase="https://github.com/my-org/repo/tree/main/docs">
Content rendered inside the edit link shown at the bottom of the TOC. Set to null to disable the link entirely.
feedback
object
Configuration for the inline feedback link that opens a pre-filled GitHub issue.

The search component rendered in the navbar. Defaults to the built-in <Search /> from nextra/components. Replace with a custom component or set to null to disable search entirely.

Dark Mode & Theming

darkMode
boolean
default:"true"
Show or hide the dark mode toggle. When false, the theme-switch dropdown is hidden from both the sidebar footer and the standalone <ThemeSwitch> component.
themeSwitch
object
Localisation strings for the theme-switch dropdown options.
nextThemes
object
Configuration passed directly to the underlying next-themes <ThemeProvider>.

sidebar
object
Controls the appearance and behaviour of the documentation sidebar.

Table of Contents (TOC)

toc
object
Configuration for the in-page Table of Contents panel shown on the right side of the content area.

navigation
boolean | { next: boolean, prev: boolean }
default:"true"
Controls the previous/next page navigation links shown at the bottom of each page. Pass true/false to enable or disable both links at once, or pass an object to control them individually.
// Disable only the "previous" link
<Layout navigation={{ prev: false, next: true }}>

Miscellaneous

copyPageButton
boolean
default:"true"
Show or hide the Copy page content button that appears at the top of the content area, allowing users to copy the full page text to the clipboard.
lastUpdated
ReactElement
default:"<LastUpdated />"
A <LastUpdated> element used to render the last-updated timestamp beneath each page. Must be a <LastUpdated> component — plain strings or other elements are rejected at runtime.
import { LastUpdated } from 'nextra-theme-docs'
<Layout lastUpdated={<LastUpdated locale="de">Zuletzt aktualisiert</LastUpdated>}>
i18n
Array<{ locale: string, name: string }>
default:"[]"
Language switcher configuration. Each entry maps a Next.js locale string (from next.config i18n.locales) to a human-readable display name shown in the dropdown. When the array is empty, the locale switcher is hidden.
<Layout
  i18n={[
    { locale: 'en', name: 'English' },
    { locale: 'zh-CN', name: '中文' },
    { locale: 'de', name: 'Deutsch' }
  ]}
>

Full configuration example

The example below shows a production-ready root layout with all commonly used props configured:
app/layout.tsx
import { Footer, Layout, Navbar } from 'nextra-theme-docs'
import { Banner, Head } from 'nextra/components'
import { getPageMap } from 'nextra/page-map'
import 'nextra-theme-docs/style.css'

const banner = (
  <Banner storageKey="v4-release">
    🎉 Version 4.0 is out — <a href="/changelog">see what's new</a>
  </Banner>
)
const navbar = (
  <Navbar
    logo={<b>Acme Docs</b>}
    projectLink="https://github.com/acme/docs"
  />
)
const footer = (
  <Footer>MIT {new Date().getFullYear()} © Acme Inc.</Footer>
)

export default async function RootLayout({ children }) {
  return (
    <html lang="en" dir="ltr" suppressHydrationWarning>
      <Head />
      <body>
        <Layout
          banner={banner}
          navbar={navbar}
          footer={footer}
          pageMap={await getPageMap()}
          docsRepositoryBase="https://github.com/acme/docs/tree/main/docs"
          editLink="Edit this page on GitHub"
          feedback={{ labels: 'feedback,docs' }}
          sidebar={{ autoCollapse: true, defaultMenuCollapseLevel: 1 }}
          toc={{ backToTop: 'Back to top', float: true }}
          navigation={{ prev: true, next: true }}
          darkMode
          i18n={[
            { locale: 'en', name: 'English' },
            { locale: 'fr', name: 'Français' },
          ]}
        >
          {children}
        </Layout>
      </body>
    </html>
  )
}
Define your navbar, footer, and banner elements outside the layout function so they are not re-created on every render. Because these are Server Components the values are serialised once at build time.

Build docs developers (and LLMs) love