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

- [ ホーム ](/ja/) 
/
- [ 作成方法 ](/ja/how-to-create/) 
/
- Vercelガイド            
# Vercel での `llms.txt`

3つの方法があります。public/内の静的ファイル（設定不要）、Next.js App Router Route Handler、または柔軟性を最大化するVercel Edge Functionです。

最終更新: 2026年4月22日

このページの内容

- [ アプローチ 1, public/ 内の静的ファイル ](#approach-1)
- [ 方式2：Next.js App Router の Route Handler ](#approach-2)
- [ アプローチ 3、Vercel Edge 関数 ](#edge)
- [ Cache-Control およびエッジネットワークの挙動 ](#cache)
- [ デプロイ後に検証すること ](#verify)            
## アプローチ1、次の場所に静的ファイルを配置： `public/`

最も簡単で信頼性の高い選択肢です。Vercelは、フレームワークの静的アセットディレクトリ内にあるすべてのファイルをグローバルEdge
Networkから直接配信します。コード変更も設定もランタイムコストもありません。
static file, framework directory map    コピー     

```
# 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
```

**使用すべき場面：** あなたの `llms.txt` コンテンツが比較的安定しており、手動またはビルドスクリプトで更新する場合に適しています。大半のサイトにとって、これが適切なデフォルトです。

例

Vercel + GitHub の連携

VercelはGitHubリポジトリに直接接続します。本番ブランチへのpushごとにビルドとデプロイが実行されます。
public/llms.txt  だけで十分です。Vercelは新しいデプロイのたびに自動でキャッシュを無効化します。

## 方式2：Next.js App Router の Route Handler

Vercel上でNext.jsを使用している場合、最も簡潔な動的アプローチは、App RouterのRoute Handlerを `app/llms.txt/route.ts`。
`export const dynamic = 'force-static'`、Vercel
はビルド時に事前レンダリングし、エッジで出力をキャッシュします。これは実質的に静的ファイルの配信と同じですが、データから生成されます。
app/llms.txt/route.ts    コピー     

```
// 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',
},
});
}

```

本当に動的なコンテンツを毎回のリクエストで取得する必要がある場合（例:
ライブCMSから取得する場合）は、force-staticを削除してください。その場合でも、 `force-static` （ライブCMSなどから）リクエストごとに取得する真に動的なコンテンツが必要な場合。この場合もVercelは、
`Cache-Control` ヘッダー。

Pages Router と `llms-full.txt` の生成については、
[専用の Next.js ページ](/ja/llms-txt-nextjs/).

## アプローチ 3、Vercel Edge 関数

動的生成が必要な Next.js 以外のプロジェクトでは、Vercel Edge Function と `vercel.json` をマッピングするrewriteを設定します： `/llms.txt` 関数へ：
api/llms.ts, Edge Function    コピー     

```
// 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    コピー     

```
// 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はVercel のグローバル Edge
Network上で、コールドスタート時間をほぼゼロにして実行されます。 生成に適しています `llms.txt` から、完全なサーバーを用意せずに生成できます。

警告

/public/ とのルート競合

静的な  public/llms.txt  と、同じ パスにAPIルートまたはEdge Functionがある場合、Vercelでは静的ファイルが優先される。プロジェクトごとに一つの方法を使う。

## Cache-Control およびエッジネットワークの挙動

次の場所にある静的ファイルの場合: `public/`,
Vercelはキャッシュヘッダーを自動的に設定します。ルート ハンドラーおよびエッジ関数については、 `Cache-Control` を明示的に設定します。

- `public, max-age=3600, stale-while-revalidate=86400`。手動でキュレーションするファイルに推奨されます。 
- `public, s-maxage=86400, stale-while-revalidate=604800`,
安定したコンテンツに適した積極的なエッジキャッシュです。 
- `public, max-age=0, s-maxage=300`、CMS由来のコンテンツ向けの5分間のエッジキャッシュです。   
Vercelは新しいデプロイのたびにCDNキャッシュを自動消去するため、更新した `llms.txt`.

## デプロイ後に検証すること
verify    コピー     

```
# 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}"
```

ヘッダーを確認したら、公開URLを [バリデーター](/ja/validator/)
仕様への適合を確認します。H1が正確に1つ、リンク構文が有効（`- [title](https://...)`）、すべてのURLが絶対URLで、空のセクションがないこと。

→ [完全な作成ガイド](/ja/how-to-create/) &middot;
[Cloudflare Pages ガイド](/ja/llms-txt-cloudflare/) &middot;
[Next.js ガイド](/ja/llms-txt-nextjs/)

## ソース

- [ llmstxt.org、コミュニティによる提案 ](https://llmstxt.org/)
- [ Vercel、Edge Functions ](https://vercel.com/docs/functions)
- [ Vercel、/public/ 内の静的ファイル ](https://vercel.com/docs/builds/configure-a-build#output-directory)
