Nextra builds a page map at compile time — a tree ofDocumentation 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.
PageMapItem nodes that describes every MDX file, folder, and _meta configuration in your content directory. The nextra/page-map module exposes functions to retrieve this tree at request time, transform it for custom navigations, and even generate it from arbitrary file-path arrays for remote or dynamically-sourced content.
getPageMap()
Retrieves the compiled page-map tree for a given route. Under the hood, Nextra generates the tree during the webpack/Turbopack build and embeds it as a module;getPageMap() imports that module and navigates to the requested route segment.
The route path to retrieve the page map for. Use
/ to get the full root
tree, a segment like /blog to get just the children under that path, or a
locale-prefixed path like /en when i18n is configured.Promise<PageMapItem[]> — an array of Folder, MdxFile, and
MetaJsonFile items representing the content at the requested route.
getPageMap() throws an Error when the specified route segment does not
exist in the compiled map. Make sure the route matches an actual folder in
your content directory.Usage in a root layout
The most common usage is passing the full page map to your theme’s layout component so it can render the sidebar and breadcrumbs:app/layout.tsx
Scoping by route
You can pass a specific route to retrieve only the children of that section, useful for section-level layouts:app/blog/layout.tsx
normalizePageMap()
Normalizes a raw page map, resolving page titles and order from_meta.js files and filling in default titles derived from filenames where no explicit title is set.
A raw page-map array, typically as returned by
getPageMap() or built via
convertToPageMap().PageMapItem[] — a new array with titles resolved and items
ordered according to their corresponding _meta configuration.
convertToPageMap()
Converts a flat array of file paths into a hierarchicalPageMapItem tree. This is the primary entry point for working with remote or externally-sourced content where you can enumerate file paths but don’t have them on disk at build time.
An array of file paths relative to the project root. Paths may originate from
content/, src/content/, or app/ directories. _meta files are
automatically detected and separated from page files.An optional path prefix to prepend to all resolved routes. Useful when the
content is mounted at a sub-path (e.g.
/docs).When i18n is enabled, pass the locale string so locale-prefixed path segments
are stripped correctly from the generated routes.
The hierarchical page-map tree built from the provided file paths.
A flat map from each resolved route string to its original file path (relative
to the
content/ directory, with locale prefix stripped if provided). Useful
for looking up source files when rendering dynamic segments.mergeMetaWithPageMap()
Merges an external meta configuration record into an existing page map. Use this when you fetch_meta data from a CMS or remote source and need to apply it to a page map that was built from file paths alone.
The base page map to merge into.
A
Record<string, DynamicMetaItem> describing titles, ordering, separators,
and other metadata — the same shape as a _meta.js export.PageMapItem[] — the merged page map with meta applied.
createIndexPage()
Generates compiled MDX source code for an auto-generated index page that lists all pages in the provided map as a card grid, grouping them under separator headings where present.The page-map slice to generate cards for.
MetaJsonFile items are skipped;
separator items become ## headings.Promise<string> — serialised JavaScript (the output of
compileMdx) that can be passed directly to MDXRemote or written to a
dynamic route.
app/docs/page.tsx
getIndexPageMap()
Returns a simplified representation of a page map suitable for rendering a custom index UI. The result is an array where each entry is either a separator item or a group ofMdxFile items.
The page-map slice to process.
(SeparatorItem | MdxFile[])[] — an array that alternates between
separator headings and arrays of page items, ready to be mapped over in a React
component.
getMetadata()
A utility that resolves Next.jsMetadata from a dynamically imported page
module, handling both static metadata exports and async generateMetadata
functions.
Types
PageMapItem
Folder
The directory name as it appears on the filesystem.
The URL path segment for this folder, e.g.
'/blog'.Nested page-map items contained within this folder.
MdxFile
The filename without extension, e.g.
'getting-started'.The full URL route for this page, e.g.
'/docs/getting-started'.Optional. The parsed YAML front matter from the MDX file, typed as
Record<string, any>.MetaJsonFile
The parsed contents of a
_meta.js (or _meta.json) file, keyed by page
name. Each value is either a plain string title or a metadata object.