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

- [ Home ](/) 
/
- [ How to create ](/how-to-create/) 
/
- Vercel guide            
# llms.txt with Vercel

Three approaches: static file in public/ (zero config), Next.js App Router Route Handler, or a Vercel Edge Function for maximum flexibility.

Last updated: April 22, 2026

## Approach 1, Static file in `public/`

The simplest and most reliable option. Vercel serves every file in your framework&rsquo;s static
assets directory directly from their global Edge Network. No code changes, no configuration, no
runtime cost.
static file, framework directory map   
Copy

```
# Place llms.txt in your project's static assets directory.
#
# Framework    → file location
# Next.js      → public/llms.txt
# Astro        → public/llms.txt
# SvelteKit    → static/llms.txt
# Nuxt         → public/llms.txt
# Remix        → public/llms.txt
# Hugo         → static/llms.txt

# Vercel serves it at /llms.txt from their global Edge Network.
# No config changes needed. After deploy, verify:
curl -I https://your-domain.com/llms.txt
# Expected: HTTP/2 200 | Content-Type: text/plain | x-vercel-cache: HIT
```

**When to use this:** your `llms.txt` content is relatively stable and you
update it manually or via a build script. This is the right default for the vast majority of sites.

✓ Vercel + GitHub integration

Vercel connects directly to your GitHub repository. Every push to the production branch triggers
a build and deploy. Committing  public/llms.txt  is all you need, Vercel handles invalidation
automatically on each new deploy.

## Approach 2, Next.js App Router Route Handler

If you&rsquo;re using Next.js on Vercel, the cleanest dynamic approach is an App Router Route
Handler at `app/llms.txt/route.ts`. With
`export const dynamic = 'force-static'`, Vercel pre-renders it at build
time and caches the output at the edge, effectively identical to serving a static file, but
generated from your data.
app/llms.txt/route.ts   
Copy

```
// app/llms.txt/route.ts  (Next.js App Router)
// Vercel detects this as a static export when dynamic = 'force-static'
// and caches the output at the edge on first request.

export const dynamic = 'force-static';

export async function GET() {
const content = [
'# My Site',
'',
'> One-sentence description of what this site is about.',
'',
'## Documentation',
'',
'- [Getting started](https://yoursite.com/docs/getting-started/): first steps.',
'- [API reference](https://yoursite.com/docs/api/): full endpoint catalog.',
'',
'## Optional',
'',
'- [Changelog](https://yoursite.com/changelog/): version history.',
].join('\n');

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

```

Remove `force-static` if you need truly dynamic content fetched on every request (e.g.
from a live CMS). In that case, Vercel will still cache the response at the edge based on your `Cache-Control` header.

For a full Next.js guide including Pages Router and `llms-full.txt` generation, see the
[dedicated Next.js page](/llms-txt-nextjs/).

## Approach 3, Vercel Edge Function

For non-Next.js projects that need dynamic generation, use a Vercel Edge Function combined with
a `vercel.json` rewrite to map `/llms.txt` to the function:
api/llms.ts, Edge Function   
Copy

```
// api/llms.txt.ts, Vercel Edge Function
// Place this file in the /api directory.
// Vercel routes requests to /api/llms.txt by default,
// so use a vercel.json rewrite to map /llms.txt → /api/llms.txt

import type { VercelRequest, VercelResponse } from '@vercel/node';

export const config = {
runtime: 'edge', // Runs on Vercel's Edge Network
};

export default function handler(req: Request): Response {
const content = [
'# My Site',
'',
'> One-sentence description.',
'',
'## Core pages',
'',
'- [Getting started](https://yoursite.com/docs/getting-started/): first steps.',
].join('\n');

return new Response(content, {
headers: {
'Content-Type': 'text/plain; charset=utf-8',
'Cache-Control': 'public, max-age=3600, s-maxage=86400',
},
});
}

```
vercel.json, rewrite rule   
Copy

```
// vercel.json, rewrite /llms.txt to your Edge Function or API Route
// Only needed if you're not using Next.js App Router (which handles routing natively)

{
"rewrites": [
{ "source": "/llms.txt", "destination": "/api/llms" }
]
}

```

Edge Functions run on Vercel&rsquo;s global Edge Network with near-zero cold start time.
They&rsquo;re ideal for generating `llms.txt` from a KV store or external API without a
full server.

⚠ Route conflict with /public/

If both a static  public/llms.txt  and an API route or Edge Function exist for the same
path, the static file takes precedence on Vercel. Use one approach per project.

## Cache-Control and Edge Network behaviour

For static files in `public/`, Vercel sets cache headers automatically. For Route
Handlers and Edge Functions, set `Cache-Control` explicitly:

- `public, max-age=3600, stale-while-revalidate=86400`, recommended for
manually-curated files. 
- `public, s-maxage=86400, stale-while-revalidate=604800`, aggressive edge caching,
good for stable content. 
- `public, max-age=0, s-maxage=300`, 5-minute edge cache for CMS-driven content.   
Vercel automatically purges the CDN cache on every new deployment, so you don&rsquo;t need to
manually invalidate after pushing an updated `llms.txt`.

## Verify after deploy
verify   
Copy

```
# Check headers, look for Content-Type and x-vercel-cache
curl -I https://yoursite.com/llms.txt

# Inspect content
curl https://yoursite.com/llms.txt

# Force-revalidate after a new deploy (Vercel auto-purges on deploy)
# For manual purge via Vercel REST API:
curl -X POST "https://api.vercel.com/v1/projects/{PROJECT_ID}/purge" \
-H "Authorization: Bearer {VERCEL_TOKEN}"
```

After verifying headers, paste your live URL into the [validator](/validator/)
to confirm spec compliance: exactly one H1, valid link syntax (`- [title](https://...)`), all URLs absolute, no empty sections.

&rarr; [Full creation guide](/how-to-create/) &middot;
[Cloudflare Pages guide](/llms-txt-cloudflare/) &middot;
[Next.js guide](/llms-txt-nextjs/)

## Sources

- [ llmstxt.org, official spec ](https://llmstxt.org/)
- [ Vercel, Edge Functions ](https://vercel.com/docs/functions/edge-functions)
- [ Vercel, Static files in /public/ ](https://vercel.com/docs/projects/project-configuration#public-directory)           
On this page

- [ Approach 1, Static file in public/ ](#approach-1)
- [ Approach 2, Next.js App Router Route Handler ](#approach-2)
- [ Approach 3, Vercel Edge Function ](#edge)
- [ Cache-Control and Edge Network behaviour ](#cache)
- [ Verify after deploy ](#verify)
