---
title: Nextra llms.txt and Markdown endpoint setup
description: Integrate next-ai-ready with a Nextra 4 App Router documentation site without replacing Nextra navigation, search, themes, or MDX rendering.
canonical_url: https://nextaiready.com/en/docs/guides/nextra-ai-ready
url: https://nextaiready.com/en/docs/guides/nextra-ai-ready
last_updated: 2026-11-24
updated: 2026-11-24
author: next-ai-ready team
summary: Integrate next-ai-ready with a Nextra 4 App Router documentation site without replacing Nextra navigation, search, themes, or MDX rendering.
topics: [nextra, nextjs, llms.txt, mdx]
---

# Nextra llms.txt and Markdown endpoint setup

[Nextra 4](https://nextra.site/docs) is a Next.js App Router framework for content-focused sites.
Keep Nextra responsible for the human-facing documentation experience. Add `next-ai-ready` beside it
when you want synchronized `/llms.txt`, page Markdown, semantic discovery, and optional MCP resources.

Not using Nextra? Start with the framework-neutral
[Next.js App Router llms.txt walkthrough](./nextjs-llms-txt).

This guide supports Nextra's root `content/` and `app/` layouts as well as their `src/` equivalents.
It does not support Nextra 1-3 sites that still use the Pages Router.

**Verified setup.** The [runnable example](#executable-reference) uses Nextra `4.6.1`,
Next.js `16.2.6`, and React `19.2.4`. You can use this guide with an existing Nextra 4 App Router
site. If you hit a theme layout error, check the [Zod 4.4 workaround](#nextra-4-6-1-and-zod-4-4-compatibility).

Install and initialize in your Nextra project, point both tools at the same content, and wrap your
existing Next.js config. After deploying, [verify both representations of one page](#verify-html-and-markdown-for-the-same-page).

## 1. Install and initialize

From the Nextra application directory:

```bash
pnpm add next-ai-ready
pnpm exec next-ai-ready init
```

`init` adds the AI routes and an `ai-ready.config.mjs` file. It does not replace Nextra's theme,
catch-all page, search configuration, or MDX components.

For a first end-to-end run with the SDK, use the [Quickstart](./quickstart) to verify a Markdown response. Then apply the content and plugin setup below to your Nextra project.

## 2. Point both systems at the same content

Nextra supports Markdown and MDX in `content/`, `src/content/`, `app/`, or `src/app/`. The default
next-ai-ready scanner covers those locations. For an explicit Nextra content directory, keep the
configuration narrow:

```js
import { defineConfig } from "next-ai-ready"

export default defineConfig({
  site: {
    name: "Acme Docs",
    baseUrl: "https://docs.example.com",
    description: "Documentation for Acme developers.",
  },
  content: ["content/**/*.{md,mdx}"],
})
```

Use `src/content/**/*.{md,mdx}` instead when the Nextra project uses a `src/` directory. Frontmatter
`description` is accepted as a page summary, so existing Nextra content does not need duplicate
metadata solely for next-ai-ready.

## 3. Compose the Next.js plugins

Keep Nextra's existing plugin and wrap the resulting Next.js config with `withAiReady()`:

```js
import nextra from "nextra"
import { withAiReady } from "next-ai-ready/config"

const withNextra = nextra({
  // Existing Nextra options stay here.
})

const nextConfig = withNextra({})

export default withAiReady({ agentReadable: true })(nextConfig)
```

This composition preserves Nextra's MDX handling and adds content negotiation for AI-readable page
responses. Do not enable Next.js `output: "export"`; the generated runtime handlers require a server.

### Nextra 4.6.1 and Zod 4.4 compatibility

Nextra `4.6.1` currently declares a Zod range that can resolve its private dependency to Zod `4.4.x`.
That combination can fail `nextra-theme-docs` layout validation before a page renders. Until the
upstream fix ships, pin only Nextra's private copies in the workspace root:

```json
{
  "pnpm": {
    "overrides": {
      "nextra>zod": "4.3.6",
      "nextra-theme-docs>zod": "4.3.6"
    }
  }
}
```

Keep next-ai-ready's Zod 4 dependency unchanged. This workaround is scoped only to Nextra's private copies and is
tracked upstream in [Nextra #4989](https://github.com/shuding/nextra/issues/4989) and
[#5036](https://github.com/shuding/nextra/issues/5036); remove the override once a fixed Nextra
release passes the fixture.

After applying the override and rebuilding, [check HTML and Markdown for the same page](#verify-html-and-markdown-for-the-same-page).

## 4. Build and verify

```bash
pnpm exec next-ai-ready build
pnpm exec next-ai-ready doctor --score
pnpm build
```

### Verify HTML and Markdown for the same page

Use your deployment's origin and an existing Nextra page path. The fixture serves
`/getting-started`. Append `.md` to the page path to request its Markdown representation.
To run these commands against the started fixture, use `http://127.0.0.1:3321` as the origin.

```bash
curl -fsS -i -H 'Accept: text/html' https://docs.example.com/getting-started
curl -fsS -i https://docs.example.com/getting-started.md
```

The first response should be `200` with `Content-Type: text/html`, the Nextra layout, and the
page content. The second should be `200` with `Content-Type: text/markdown`, the heading and
body of the same page, and a canonical `Link` header pointing to the production HTML URL.
The local fixture uses `https://nextra-fixture.example` as its configured canonical origin.

Check discovery with `curl -fsS https://docs.example.com/llms.txt` and verify it lists the page.
Run `pnpm exec next-ai-ready audit https://docs.example.com/getting-started --version 3` for
the broader audit. A browser request to an unknown page should still return `404`.

### Troubleshooting and rollback

- Build order: run the AI build (`next-ai-ready build`) before `next build`. This fixture's `prebuild`
  invokes the workspace CLI to create the graph before Nextra builds.
- Static export: runtime handlers and content negotiation require a server, not `output: "export"`.
- Plugin composition: retain `withNextra` and existing options; wrap only the final config with `withAiReady`.
- Rollback: remove the `withAiReady` wrapper, AI route stubs, and the fixture-specific workspace `prebuild`
  wiring. Keep Nextra's plugin, theme, MDX content, navigation, and search intact.

## Executable reference

The repository includes an [executable Nextra 4 fixture](https://github.com/mustcanbedo/next-ai-ready/tree/main/examples/nextra-docs)
validated with Nextra `4.6.1`, Next.js `16.2.6`, and React `19.2.4` in a production build.
This is a first-party compatibility demonstration using this repository's workspace source. It is not
an independent installation test of npm latest, external adoption, Nextra endorsement, or evidence
of increased search traffic.

### Published npm package check

On 2026-11-23, a standalone app installed `next-ai-ready@0.1.0-alpha.22` from the public npm registry
with Node.js `22.22.1` and pnpm `9.12.0`. It used Nextra and its docs theme `4.6.1`, Next.js
`16.2.6`, and React `19.2.4`. The check confirmed Zod `4.3.6` for Nextra and the theme, and
Zod `4.4.3` for the SDK.

From the repository root, run the [public-registry smoke script](https://github.com/mustcanbedo/next-ai-ready/blob/main/examples/nextra-docs/scripts/public-registry-smoke.mjs):

```bash
node examples/nextra-docs/scripts/public-registry-smoke.mjs 0.1.0-alpha.22
```

The production build, the shared-content graph check, and all nine HTTP checks passed.
`doctor` reported **0 errors and 3 warnings** for JavaScript route detection, missing author
metadata, and missing JSON-LD on the example pages.

### Workspace example

After cloning the repository, run these commands in order from its root:

```bash
corepack pnpm install --frozen-lockfile
corepack pnpm --filter next-ai-ready... build
corepack pnpm --filter @next-ai-ready/example-nextra-docs build
corepack pnpm --filter @next-ai-ready/example-nextra-docs test
```

To view the production UI after the test has finished:

```bash
corepack pnpm --filter @next-ai-ready/example-nextra-docs start --hostname 127.0.0.1 --port 3321
```

![Nextra Getting started documentation rendered by the local production build](/guides/nextra/html.jpg)

This screenshot is from the running production server. Visit `http://127.0.0.1:3321/getting-started`
to inspect it yourself. The same `examples/nextra-docs/content/getting-started.mdx` feeds these outputs:

| Output                                         | Verified contract                                                       |
| ---------------------------------------------- | ----------------------------------------------------------------------- |
| HTML `/getting-started`                        | `200`, retaining the Nextra theme and page content                      |
| `/llms.txt`                                    | `200`, listing the page's canonical URL                                 |
| `/llms-full.txt`                               | `200`, including the body and frontmatter FAQ                           |
| `/getting-started.md`                          | `200 text/markdown`, with body and canonical Link header                |
| AI JSON `/getting-started.ai.json`             | `200 application/json`, with `route: /getting-started`                  |
| `/getting-started`, `Accept: text/markdown`    | `200`, serving the same page as Markdown                                |
| Missing `/does-not-exist`, `Accept: text/html` | HTML `404`                                                              |
| Same missing page, `Accept: text/markdown`     | Markdown `200`, `document_status: "not_found"`, `X-Robots-Tag: noindex` |

The example excludes MCP and callable actions. `nextra-fixture.example` is an example canonical
domain; replace `site.baseUrl` in `ai-ready.config.mjs` with your production domain and rebuild.

![ai-ready.config.mjs on the public GitHub main branch](/guides/nextra/config.jpg)

This screenshot comes from the [public configuration source](https://github.com/mustcanbedo/next-ai-ready/blob/main/examples/nextra-docs/ai-ready.config.mjs).
It shows the content glob and example domain, not a terminal test result.

The production smoke passed 10 checks: one shared-content graph check and nine HTTP checks.
Inspect the assertions in the [production smoke script](https://github.com/mustcanbedo/next-ai-ready/blob/main/examples/nextra-docs/scripts/compatibility-smoke.mjs).
The 2026-10-02 workspace-source run reported `0 errors / 5 warnings` from `doctor`.
Three concern diagnostic heuristics for Knowledge-only OpenAPI, JavaScript route stubs, and the
workspace CLI prebuild. The other two flag author metadata and JSON-LD that this fixture does not configure.

## Start with the Knowledge plane

For an initial Nextra integration, ship only content discovery and page retrieval. Add MCP or callable
actions later when the site has a concrete agent workflow and an authentication policy.
