Route Handler
معالج المسار
GLS-000085
Definition
A file in the Next.js App Router that handles HTTP requests — the App Router equivalent of an API Route.
ملف في Next.js App Router يعالج طلبات HTTP — مكافئ App Router لمسار API.
Why It Matters
Every admin action and public API on 404Fault (/api/glossary/terms, /api/admin/*) is a route handler. They are the server-side backbone of the app.
كل إجراء أدمن وAPI عام في 404Fault (/api/glossary/terms و/api/admin/*) هو معالج مسار. إنها العمود الفقري من جانب الخادم للتطبيق.
Full Definition
Example Usage
“src/app/api/glossary/terms/route.ts exports a GET function that queries Firestore and returns published terms as JSON.”
“src/app/api/glossary/terms/route.ts يُصدِّر دالة GET تستعلم Firestore وتُعيد المصطلحات المنشورة كـ JSON.”
AI Builder Tips
Avoid these mistakes when using Route Handler:
Placing route.ts in the same folder as page.tsx — they cannot coexist at the same path
Forgetting export const dynamic = 'force-dynamic' when the response depends on request data
Sign in to unlock guided AI explanations from AI Teacher.
Generate a Prompt
Copy this prompt and use it directly with any AI model — no setup needed.
Help me build a project using Route Handler. Explain: 1. What is Route Handler and why it matters 2. The core architecture and required tools 3. Step-by-step implementation plan 4. Common mistakes to avoid: Placing route.ts in the same folder as page.tsx — they cannot coexist at the same path, Forgetting export const dynamic = 'force-dynamic' when the response depends on request data 5. Best practices and production tips