llms.txt
Serve content through your existing docs API — no extra route files needed. Just enable it in your config.
What is llms.txt?
llms.txt is a standard for making website content accessible to LLMs. In Next.js, withDocs()
serves conventional public aliases that rewrite to your existing /api/docs endpoint:
/llms.txt— The default concise markdown listing of all pages with titles, URLs, and descriptions/llms-full.txt— The default full stripped content of every page, ready for LLM consumption/.well-known/llms.txt— Alias for/llms.txt/.well-known/llms-full.txt— Alias for/llms-full.txt
The shared API handler remains the source of truth:
/api/docs?format=llms— A concise markdown listing of all pages with titles, URLs, and descriptions/api/docs?format=llms-full— The full stripped content of every page, ready for LLM consumption
Quick Start
llmsTxt: {
enabled: true,
baseUrl: "https://docs.example.com",
}That's it. The existing API handler serves the content automatically — no extra route files needed.
Configuration Reference
All options go inside the llmsTxt object in docs.config.ts:
export default defineDocs({
llmsTxt: {
// ... options
},
});llmsTxt.enabled
Enable or disable llms.txt generation.
| Type | Default |
|---|---|
boolean | false |
llmsTxt.baseUrl
Base URL prepended to all page links in the generated files.
| Type | Default |
|---|---|
string | "" |
llmsTxt: {
enabled: true,
baseUrl: "https://docs.example.com",
}llmsTxt.siteTitle
Title shown at the top of the generated files. Falls back to nav.title if not set.
| Type | Default |
|---|---|
string | nav.title |
llmsTxt.siteDescription
Description shown below the title.
| Type | Default |
|---|---|
string | undefined |
How It Works
No extra route files are needed. The existing API handler (/api/docs on Next.js, or your framework's equivalent) serves the llms.txt content when you pass the format query parameter:
GET /api/docs?format=llms— concise page listingGET /api/docs?format=llms-full— full page content
In Next.js, withDocs() also adds the crawler-friendly public aliases automatically:
GET /llms.txt— default concise routeGET /llms-full.txt— default full-content routeGET /.well-known/llms.txtGET /.well-known/llms-full.txtGET /.well-known/agent.jsonfor the preferred agent discovery spec that references thosellms.txtroutesGET /.well-known/agentas the fallback agent discovery alias
Those aliases rewrite to the same shared API output, so there is still only one content pipeline.
The agent discovery spec also advertises defaultTxt: "/llms.txt" and
defaultFull: "/llms-full.txt" so integrations can use the intended defaults without adding their
own framework-specific routes. TanStack Start, SvelteKit, Astro, and Nuxt can use the shared API
query routes directly.
Output Example
/api/docs?format=llms
# My Documentation
> A modern docs framework
## Pages
- [Introduction](https://docs.example.com/docs): Getting started guide
- [Installation](https://docs.example.com/docs/installation): How to install
- [Configuration](https://docs.example.com/docs/configuration): Config reference/api/docs?format=llms-full
# My Documentation
> A modern docs framework
## Introduction
URL: https://docs.example.com/docs
Getting started guide
Full page content here...
---
## Installation
URL: https://docs.example.com/docs/installation
How to install
Full page content here...Footer Links
When enabled, llms.txt and llms-full.txt links automatically appear in the page footer next to "Edit on GitHub", pointing to the public /llms.txt and /llms-full.txt routes.
Full Example
export default defineDocs({
entry: "docs",
llmsTxt: {
enabled: true,
baseUrl: "https://docs.example.com",
siteTitle: "My Project Docs",
siteDescription: "Comprehensive documentation for My Project",
},
});How is this guide?