Home /

docs

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:

The shared API handler remains the source of truth:

Quick Start

docs.config.ts
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:

docs.config.ts
export default defineDocs({
  llmsTxt: {
    // ... options
  },
});

llmsTxt.enabled

Enable or disable llms.txt generation.

TypeDefault
booleanfalse

llmsTxt.baseUrl

Base URL prepended to all page links in the generated files.

TypeDefault
string""
llmstxt-baseurl.ts
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.

TypeDefault
stringnav.title

llmsTxt.siteDescription

Description shown below the title.

TypeDefault
stringundefined

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:

In Next.js, withDocs() also adds the crawler-friendly public aliases automatically:

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

api-docs-format-llms.md
# 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

api-docs-format-llms-full.md
# 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...

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

docs.config.ts
export default defineDocs({
  entry: "docs",
  llmsTxt: {
    enabled: true,
    baseUrl: "https://docs.example.com",
    siteTitle: "My Project Docs",
    siteDescription: "Comprehensive documentation for My Project",
  },
});