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.
nextra() function is the default export of the nextra package and serves as the entry point for integrating Nextra into your Next.js project. It accepts a configuration object and returns a higher-order function that wraps your next.config — letting Nextra instrument the webpack and Turbopack pipelines, register MDX loaders, and inject the page-map build step transparently.
Function Signature
nextra() once with your Nextra options to get withNextra, then pass your Next.js config object to that wrapper:
next.config.mjs
The returned
withNextra function merges Nextra’s webpack rules into your existing Next.js config rather than replacing it. All standard NextConfig options continue to work as expected.NextraConfig Options
Core Options
Enable the copy button for all code blocks by default, without needing to set
the
copy=true attribute in each code block’s metadata string. You can still
disable the button on a per-block basis with copy=false.Enable search functionality powered by Pagefind. When
enabled, Nextra adds the
data-pagefind-body attribute to the <main>
element so Pagefind can index your content.Automatically optimise static image imports written with Markdown syntax (e.g.
). Nextra will pass these through Next.js <Image>
for automatic resizing and format selection.Adds an estimated reading time to the front matter of every
.md and .mdx
file under the readingTime key. Powered by the
reading-time package.Enable or disable syntax highlighting for code blocks. Highlighting is
performed at build time by Rehype Pretty Code backed by Shiki. Disable this if you want to use a different client-side highlighter.
Allows additional HTML elements to be replaced by components defined in
mdx-components.js. By default Nextra only replaces <details> and
<summary>. Pass extra tag names here to extend that behaviour.Serve your
.md and .mdx files from the content directory at a custom
URL path instead of the root (/). Must begin with / and must not end
with / (except for the root itself).Prefixes the current locale to all links in the page-map. Useful for i18n
setups where you manage routing yourself and don’t want to use Nextra’s built-in
middleware.
mdxOptions
Fine-grained control over the MDX compilation pipeline. All sub-options are
optional.
latex
Enable LaTeX math rendering. Pass
true to use KaTeX with default settings,
or supply a renderer-specific object for fine-grained control.