<!-- Generated from llms-txt-nuxt/index.html. The canonical document is the HTML page. -->

- [ Home ](/) 
/
- [ How to create ](/how-to-create/) 
/
- Nuxt.js guide            
# `llms.txt` for Nuxt.js

Four approaches for Nuxt: a static file in public/ (zero config), a Nitro server route for dynamic generation, a server route that queries Nuxt Content v3 collections, or the nuxt-llms module.

Last updated: October 29, 2026

On this page

- [ Option 1: static file in public/ ](#static)
- [ Option 2: server API route ](#server-route)
- [ Option 3: Nuxt Content auto-generate ](#nuxt-content)
- [ Option 4: nuxt-llms module ](#nuxt-llms)
- [ Nitro and deployment targets ](#nitro)
- [ Verify ](#verify)               
Note

Which approach to use?

Use the  static file  if your  llms.txt  rarely changes. Use a  server route  if you want to generate it from your content at request time or build time. Use  Nuxt Content integration  or the  nuxt-llms  module if you manage docs in Markdown files with Nuxt Content.

## Option 1: static file in public/

Nuxt copies everything in the `public/` directory directly into the build output, served
at the root of your site. Place your file at `public/llms.txt` and it will be available at `/llms.txt` on every deployment target.
public/llms.txt, directory structure    Copy     

```
# Nuxt static file approach
#
# Place your file at: public/llms.txt
# Nuxt copies everything in public/ directly to the build output.
#
# Project structure:
# your-nuxt-app/
# ├── public/
# │   └── llms.txt   ← add this
# ├── pages/
# └── nuxt.config.ts
#
# No configuration needed. Works with all deployment presets.

```

This approach requires no configuration and works identically across all Nitro presets: **node-server**, **cloudflare-pages**, **vercel**, **netlify**, and **static**.

## Option 2: server API route

Create a file at `server/routes/llms.txt.ts`. Nuxt's Nitro engine maps files in `server/routes/` directly to URL paths, so this file is served at exactly `/llms.txt` with no additional
routing config.
server/routes/llms.txt.ts    Copy     

```
// server/routes/llms.txt.ts
// Nuxt server route, served at /llms.txt
export default defineEventHandler((event) => {
const content = `# Your Site

> One-sentence description of what your site or product does.

## Documentation

- [Getting Started](https://yoursite.com/docs/start): Install and configure in minutes.
- [API Reference](https://yoursite.com/docs/api): Full endpoint catalog with examples.

## Product

- [Overview](https://yoursite.com/product): Core features and capabilities.
- [Pricing](https://yoursite.com/pricing): Plans and billing details.

## Optional

- [Changelog](https://yoursite.com/changelog): Release history.
- [GitHub](https://github.com/your-org/your-repo): Source code.
`;

setResponseHeader(event, 'Content-Type', 'text/plain; charset=utf-8');
setResponseHeader(event, 'Cache-Control', 'public, max-age=3600, stale-while-revalidate=86400');
return content;
});

```

Use `setResponseHeader` from the `h3` library (bundled with Nuxt) to set the
correct `Content-Type`. Add a `Cache-Control` header so CDN edges cache the response and reduce origin load.

The prerendering crawler only discovers routes linked from your pages, so a server route such as
`/llms.txt` is not prerendered automatically. To emit it as a static file at build time,
add a route rule (or list it in the `prerender.routes` array, as the Nuxt docs show for
`/sitemap.xml` and `/robots.txt`):
nuxt.config.ts, prerender /llms.txt    Copy     

```
// nuxt.config.ts
// Prerender the server route so it is written as a static file at build time.
export default defineNuxtConfig({
routeRules: {
'/llms.txt': { prerender: true },
},
});

```

## Option 3: Nuxt Content auto-generate

If you use [Nuxt Content](https://content.nuxt.com/) for documentation, you can query your
content collection and build the link list automatically. This ensures `llms.txt` stays
in sync with your docs without manual updates.
server/routes/llms.txt.ts, Nuxt Content    Copy     

```
// server/routes/llms.txt.ts
// Auto-generate llms.txt from Nuxt Content v3 documents.
// 'docs' must be a collection defined in content.config.ts.
export default defineEventHandler(async (event) => {
// Server-side, queryCollection takes the event as its first argument
const docs = await queryCollection(event, 'docs')
.select('path', 'title', 'description')
.all();

const links = docs
.map((doc) => `- [${doc.title}](https://yoursite.com${doc.path}): ${doc.description ?? ''}`.trimEnd())
.join('\n');

const body = [
'# Your Site',
'',
'> One-sentence description of your project.',
'',
'## Documentation',
'',
links,
].join('\n');

setResponseHeader(event, 'Content-Type', 'text/plain; charset=utf-8');
return body;
});

```

This uses the Nuxt Content v3 API. Content v2's `queryContent()` and
`serverQueryContent()` are replaced by `queryCollection()`, which queries
a collection declared in `content.config.ts`, and the `_path` field is now
`path`. Adjust the collection name (`docs`) and selected fields to match
your content structure. Run the [validator](/validator/) after deploys to catch any formatting
regressions.

## Option 4: nuxt-llms module

The `nuxt-llms` module (published under the `nuxt-content` GitHub organization;
version 0.3.1 released 2026-10-27) generates `llms.txt` from configuration. When it is
installed alongside Nuxt Content v3, Nuxt Content injects its
`page` collections into the module, and the Nuxt Content docs state that
`/llms.txt` is then generated and prerendered automatically. Install it with
`npm install nuxt-llms`, then:
nuxt.config.ts, nuxt-llms    Copy     

```
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@nuxt/content', 'nuxt-llms'],
llms: {
domain: 'https://your-site.com',
title: 'Your Site Name',
description: 'A brief description of your site',
},
});

```

Sections and content filters can be configured under `llms.sections`; see the [Nuxt Content LLMs integration](https://content.nuxt.com/docs/integrations/llms) for the options.

## Nitro and deployment targets

- **node-server**, server routes run as a Node.js HTTP handler. Add a reverse proxy
(nginx/Caddy) cache rule for `/llms.txt` to avoid hitting Node on every request. 
- **cloudflare-pages**, static files in `public/` are served from Cloudflare's
global CDN. Server routes become Pages Functions. See the [Cloudflare guide](/llms-txt-cloudflare/) for cache headers. 
- **vercel**, static files are Edge-cached automatically. Server routes become
Vercel Serverless or Edge Functions depending on config. 
- **static** (fully pre-rendered, for example with `nuxt generate`), the
`public/` file works as is. A server route is only included in static output if it is
prerendered: add it to `routeRules` with `prerender: true` or to
`prerender.routes`, as shown in Option 2.   
## Verify

After deploying, confirm the file is served correctly:
Verification    Copy     

```
curl -I https://yoursite.com/llms.txt
# Expected:
# HTTP/2 200
# content-type: text/plain; charset=utf-8

curl https://yoursite.com/llms.txt | head -5
# Should print the first lines of your file
```

## Related guides

- [How to create llms.txt](/how-to-create/), templates and checklist. 
- [llms.txt format reference](/llms-txt-format/), spec details. 
- [Vercel guide](/llms-txt-vercel/), deployment and cache headers. 
- [Cloudflare Pages guide](/llms-txt-cloudflare/), CDN config. 
- [Validator](/validator/) · [Generator](/generator/).         
## Sources

- [ llmstxt.org, community proposal ](https://llmstxt.org/)
- [ Nuxt docs (4.x), server directory ](https://nuxt.com/docs/4.x/directory-structure/server)
- [ Nuxt docs (4.x), prerendering ](https://nuxt.com/docs/4.x/getting-started/prerendering)
- [ Nuxt Content docs ](https://content.nuxt.com/)
- [ Nuxt Content, queryCollection ](https://content.nuxt.com/docs/utils/query-collection)
- [ Nuxt Content, migration from v2 ](https://content.nuxt.com/docs/getting-started/migration)
- [ Nuxt Content, LLMs module integration ](https://content.nuxt.com/docs/integrations/llms)
- [ nuxt-llms source ](https://github.com/nuxt-content/nuxt-llms)
