Layout

التخطيط (Layout)

GLS-000083

Beginnerreact-nextjs1 min read
next layoutroot layoutnested layoutapp layoutlayout.tsx

Definition

A wrapper component in Next.js App Router that wraps multiple pages with shared UI like navbars and footers.

مكوّن مُغلِّف في Next.js App Router يلفّ صفحات متعددة بواجهة مشتركة كشريط التنقل والتذييل.

Why It Matters

Layouts avoid repeating navbar/footer code on every page. 404Fault uses layouts to inject auth context, RTL direction, and the global tooltip engine across all pages.

التخطيطات تتجنب تكرار كود شريط التنقل/التذييل في كل صفحة. يستخدم 404Fault التخطيطات لحقن سياق المصادقة وإشارة RTL ومحرك التلميحات العالمي في جميع الصفحات.

Full Definition

In Next.js App Router, a layout.tsx file wraps all pages at its level and below. The root layout (app/layout.tsx) wraps every page on the site and includes global HTML structure, fonts, and context providers. Nested layouts can wrap specific sections — for example, app/admin/layout.tsx wraps all admin pages with an auth check.
في Next.js App Router، ملف layout.tsx يلفّ جميع الصفحات على مستواه وما دونه. التخطيط الجذري (app/layout.tsx) يلفّ كل صفحة في الموقع ويتضمن هيكل HTML العالمي والخطوط ومزودي السياق. يمكن للتخطيطات المتداخلة أن تلفّ أقسامًا محددة — على سبيل المثال، app/admin/layout.tsx يلفّ جميع صفحات الأدمن بفحص المصادقة.

Example Usage

app/layout.tsx in 404Fault sets dir='rtl' for Arabic mode and wraps every page in LanguageProvider, AuthProvider, and GlossaryProvider.

app/layout.tsx في 404Fault يضبط dir='rtl' لوضع العربية ويلفّ كل صفحة في LanguageProvider وAuthProvider وGlossaryProvider.

Knowledge Graph

Avoid these mistakes when using Layout:

1

Making the root layout a Client Component (it should be a Server Component)

2

Forgetting that layout re-renders do NOT happen on page navigation — only children re-render

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 Layout.

Explain:
1. What is Layout and why it matters
2. The core architecture and required tools
3. Step-by-step implementation plan
4. Common mistakes to avoid: Making the root layout a Client Component (it should be a Server Component), Forgetting that layout re-renders do NOT happen on page navigation — only children re-render
5. Best practices and production tips

Official Resources