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

- [ الرئيسية ](/ar/) 
/
- [ كيفية إنشاء ](/ar/how-to-create/) 
/
- دليل Vercel            
# `llms.txt` مع Vercel

ثلاثة نهوج: ملف ثابت في public/ (بلا إعداد)، أو Route Handler في Next.js App Router، أو Vercel Edge Function لأقصى قدر من المرونة.

آخر تحديث: 22 أبريل 2026

في هذه الصفحة

- [ النهج 1، ملف ثابت في public/ ](#approach-1)
- [ النهج 2: معالج مسار App Router في Next.js ](#approach-2)
- [ النهج 3، وظيفة Vercel Edge ](#edge)
- [ سلوك Cache-Control وشبكة الحافة ](#cache)
- [ تحقّق بعد النشر ](#verify)            
## النهج 1: ملف ثابت في `public/`

الخيار الأبسط والأكثر موثوقية. تقدم Vercel كل ملف في دليل الأصول الثابتة لإطارك مباشرةً من شبكة
Edge العالمية لديها. لا تغييرات في الكود ولا إعداد ولا تكلفة وقت التشغيل.
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 لديك. وكل دفع إلى فرع الإنتاج يشغّل بناءً ونشراً جديدين.
ويؤدي الالتزام  public/llms.txt  هو كل ما تحتاج إليه؛ تتولى Vercel الإبطال تلقائياً عند
كل عملية نشر جديدة.

## النهج 2: معالج المسار في Next.js App Router

إذا كنت تستخدم Next.js على Vercel، فإن أنظف نهج ديناميكي هو معالج مسار App Router في `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',
},
});
}

```

أزل `force-static` إذا احتجت إلى محتوى ديناميكي فعلاً يُجلب في كل طلب (مثلاً من CMS مباشر).
وفي هذه الحالة ستخزّن Vercel الاستجابة عند الحافة استناداً إلى `Cache-Control` الترويسة.

للاطلاع على دليل Next.js كامل يتضمن Pages Router و `llms-full.txt` للتوليد، راجع
[صفحة Next.js مخصصة](/ar/llms-txt-nextjs/).

## النهج 3، Vercel Edge Function

بالنسبة إلى مشروعات لا تستخدم Next.js وتحتاج إلى توليد ديناميكي، استخدم Vercel Edge Function مع `vercel.json` أعد الكتابة لربط `/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 العالمية بزمن بدء بارد شبه صفري. وهي مثالية لتوليد `llms.txt` من مخزن KV أو API خارجي من دون خادم كامل.

تحذير

تعارض مسار مع /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.   
تمسح 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 المباشر في [المدقّق](/ar/validator/)
لتأكيد مطابقة المواصفة: عنوان H1 واحد بالضبط، وصياغة روابط صالحة (`- [title](https://...)`)، جميع عناوين URL مطلقة ولا أقسام فارغة.

&rarr; [دليل الإنشاء الكامل](/ar/how-to-create/) &middot;
[دليل Cloudflare Pages](/ar/llms-txt-cloudflare/) &middot;
[دليل Next.js](/ar/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)
