Home /

docs

llms.txt

Serve content through your existing docs API and the default public aliases. It is enabled by default.

What is llms.txt?

llms.txt is a standard for making website content accessible to LLMs. Next.js withDocs() and the generated TanStack Start, SvelteKit, Astro, and Nuxt forwarding layer serve conventional public aliases that forward to the same docs handler:

The shared API handler remains the source of truth:

Quick Start

No config is required for the default routes. Add llmsTxt only when you want to customize the public base URL, title, description, or explicitly opt out.

docs.config.ts
llmsTxt: {
  baseUrl: "https://docs.example.com",
}

That's it. The existing API handler serves the content automatically. Next.js adds rewrites with withDocs(); TanStack Start, SvelteKit, Astro, and Nuxt add one public forwarder each so the public aliases do not need one route file per URL.

Custom Static Files

You do not need a config flag to replace the generated files. If your app already ships a native static file at the same public route, that file wins and the generated route is only used as the fallback.

FrameworkStatic file location
Next.js, Astro, Nuxt, TanStack Startpublic/llms.txt, public/llms-full.txt
SvelteKitstatic/llms.txt, static/llms-full.txt

The same convention applies to /.well-known/llms.txt and /.well-known/llms-full.txt when you publish those files in the framework's static directory. Keep llmsTxt configured only when you want generated fallback metadata such as baseUrl, siteTitle, sections, or a size budget.


Configuration Reference

All options go inside the optional llmsTxt object in docs.config.ts:

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

llmsTxt.enabled

Enable or disable llms.txt generation.

TypeDefault
booleantrue

llmsTxt.baseUrl

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

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

llmsTxt.maxChars

Character budget for generated compact llms.txt files. The default warns when a root or section file grows past 50,000 characters. llms-full.txt is intentionally not budgeted because it is the full-content fallback.

TypeDefault
{ mode?: "warn" | "error" | "off"; chars?: number }{ mode: "warn", chars: 50000 }
llmstxt-maxchars.ts
llmsTxt: {
  maxChars: {
    mode: "warn",
    chars: 50_000,
  },
}

llmsTxt.sections

Optional section-level llms.txt files for larger docs. Each matcher is a public URL pattern. The framework derives both routes from match.

llmstxt-sections.ts
llmsTxt: {
  sections: [
    {
      title: "API",
      description: "Endpoint, SDK, and integration reference pages.",
      match: "/docs/api/**",
      maxChars: {
        mode: "warn",
        chars: 25_000,
      },
    },
    {
      title: "Guides",
      description: "Task-based implementation walkthroughs.",
      match: "/docs/guides/**",
    },
  ],
}

Derived routes:

This docs site dogfoods the section feature with Guides, Customization, and Themes sections. For example, the generated compact Guides section file is /docs/guides/llms.txt, and the full-content sibling is /docs/guides/llms-full.txt. Those routes are not UI pages; they are machine-readable text responses served by the same docs API.


How It Works

The existing API handler serves the llms.txt content when you pass the format query parameter:

Next.js withDocs() and the generated TanStack Start, SvelteKit, Astro, and Nuxt forwarding layer also expose the crawler-friendly public aliases:

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 when they do not want to add the public aliases.

The compact llms.txt listing links to each page's markdown route by default, for example /docs/installation.md instead of /docs/installation. That gives agents a direct path to the machine-readable page and keeps the root index aligned with AFDocs-style checks. llms-full.txt still includes the canonical page URL in its URL: line because the content is already embedded in that file.

If apiReference is enabled, root llms.txt also includes an API Schemas section that links to /api/docs?format=openapi. Agents can fetch the schema before reading rendered endpoint docs.

When llmsTxt.sections is configured, root /llms.txt lists those section files first and only keeps unmatched pages in the root page list. Each section route serves the matching pages, and its llms-full.txt sibling serves the full matching content. No UI is added; this only changes the machine-readable route layer.

When you also want crawlers and AI agents to see an explicit access policy, publish /robots.txt with docs robots generate. The generated policy allows the public llms.txt aliases along with docs, markdown, sitemap, skill, MCP, and agent discovery routes.


Output Example

/api/docs?format=llms

api-docs-format-llms.md
# My Documentation

> A modern docs framework

## API Schemas

- [OpenAPI schema](https://docs.example.com/api/docs?format=openapi): Machine-readable API schema for tool use and API clients; rendered API reference at https://docs.example.com/api-reference

## Pages

- [Introduction](https://docs.example.com/docs.md): Getting started guide
- [Installation](https://docs.example.com/docs/installation.md): How to install
- [Configuration](https://docs.example.com/docs/configuration.md): 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...

Because llms.txt is enabled by default, 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: {
    baseUrl: "https://docs.example.com",
    siteTitle: "My Project Docs",
    siteDescription: "Comprehensive documentation for My Project",
  },
});