Middleware
الميدلوير
GLS-000035
Intermediatebackend1 min read
Next.js middlewareedge middlewaremiddleware.ts
Definition
Code that runs between a request and a response, used for auth checks, redirects, and rewrites.
كود يعمل بين الطلب والاستجابة، يُستخدم للتحقق من المصادقة وإعادة التوجيه.
Full Definition
In Next.js, Middleware is a special file (middleware.ts) that runs on the Edge Runtime before a request is processed. It can inspect, redirect, rewrite, or reject requests. Common uses: authentication checks, locale detection, A/B testing, and rate limiting.
في Next.js، الميدلوير ملف خاص (middleware.ts) يعمل على Edge Runtime قبل معالجة الطلب. يمكنه فحص الطلبات وإعادة توجيهها ورفضها. الاستخدامات الشائعة: فحص المصادقة وكشف اللغة وتحديد المعدل.
Knowledge Graph
AI Builder Tips
No documented mistakes for Middleware yet. Check related AI rules for usage guidelines.
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.
Ready-to-Use Prompt
Help me build a project using Middleware. Explain: 1. What is Middleware and why it matters 2. The core architecture and required tools 3. Step-by-step implementation plan 4. Common mistakes to avoid 5. Best practices and production tips