<!-- 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

Three approaches for Nuxt.js: a static file in public/ (zero config), a Nitro server route for dynamic generation, or auto-generation from Nuxt Content documents.

Last updated: April 22, 2026

ℹ 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  if you manage docs in Markdown files.

## 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(() => {
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.

## 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 documents
import { serverQueryContent } from '#content/server';

export default defineEventHandler(async (event) => {
// Query all docs; adjust collection name as needed
const docs = await serverQueryContent(event, '/docs')
.only(['title', 'description', '_path'])
.find();

const links = docs
.map((doc) => `- [${doc.title}](https://yoursite.com${doc._path}/): ${doc.description ?? ''}`)
.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;
});

```

Adjust the query path (`/docs`) and field names to match your content structure. Run
the [validator](/validator/) after deploys to catch any formatting regressions.

## 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), use the `public/` 
static file approach; server routes are not available in purely static output.   
## 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, official spec ](https://llmstxt.org/)
- [ Nuxt docs, server routes ](https://nuxt.com/docs/guide/directory-structure/server)
- [ Nuxt Content docs ](https://content.nuxt.com/)           
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)
- [ Nitro and deployment targets ](#nitro)
- [ Verify ](#verify)
