0Pricing
Next.js 15 Fullstack (App Router + Server Actions) · درس

التخطيطات ومكوّنات الصفحات

أتقن إنشاء التخطيطات المتداخلة ومكوّنات الصفحات ضمن بنية App Router لتنظيم واجهة المستخدم

التخطيطات ومكوّنات الصفحات درس مجاني في Next.js 15 Fullstack (App Router + Server Actions) على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Next.js 15 Fullstack (App Router + Server Actions)، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Next.js 15 Fullstack (App Router + Server Actions) 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

App Router UI Structure

The Next.js App Router organizes your application's user interface (UI) using special files: layout.js and page.js.

This structured approach helps you build consistent UIs that are easy to manage and scale across your mobile app.

What is a Layout?

A layout defines shared UI for a segment of routes. Think of it as a wrapper that surrounds your pages and other layouts.

  • Layouts can contain common elements like navigation bars, footers, or sidebars.
  • They don't re-render when navigating between pages within the same layout, improving performance.

The Root Layout File

Every App Router project must have a root layout file named app/layout.js at the top level of your app directory.

This layout defines the essential HTML structure, including the <html> and <body> tags, for your entire application.

Basic Root Layout Code

The children prop in a layout component is crucial. It represents the content of the nested layouts or pages below it.

This example shows a basic root layout with a header and footer.

app/layout.js
export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        <header>My App Header</header>
        {children}
        <footer>My App Footer</footer>
      </body>
    </html>
  );
}

What is a Page Component?

A page component is defined by a page.js file. This file contains the unique UI content specifically for a given route segment.

  • Each URL path (e.g., /, /about) typically has its own page.js.
  • It renders within its parent layout(s), filling the {children} slot.

Basic Page Component Code

This app/page.js file creates the UI for your root URL (/). It will be automatically wrapped by your app/layout.js.

app/page.js
export default function HomePage() {
  return (
    <main>
      <h1>Welcome to CoddyKit!</h1>
      <p>Start learning Next.js 15 today!</p>
    </main>
  );
}

Creating Nested Layouts

You can create nested layouts by simply adding a layout.js file inside any subfolder within your app directory.

This allows you to apply shared UI to specific sections of your app, like a dashboard or user profile, while inheriting the root layout's structure.

Nested Layout Example

Here's how you'd create a nested layout for a /dashboard route. This dashboard layout wraps all pages within the /dashboard segment.

app/dashboard/layout.js
export default function DashboardLayout({ children }) {
  return (
    <section>
      <nav>
        <p>Dashboard Navigation</p>
      </nav>
      {children} {/* This will be app/dashboard/page.js */}
    </section>
  );
}

app/dashboard/page.js
export default function DashboardPage() {
  return (
    <h1>Dashboard Overview</h1>
  );
}

Layouts & Pages Hierarchy

The rendering order for your UI components flows from the outermost layout to the innermost page:

  • app/layout.js (Root Layout)
  • app/dashboard/layout.js (Nested Layout, if applicable)
  • app/dashboard/page.js (Specific Page Content)

Each layout receives the next level of UI as its children prop.

Quick Check

Test your knowledge on how Next.js App Router structures UI.

Recap: Layouts & Pages

You've learned how Next.js App Router uses layout.js files for shared UI and page.js files for unique content specific to a route.

Understanding this fundamental structure is key to building organized and scalable Next.js applications!

الأسئلة الشائعة

هل درس «التخطيطات ومكوّنات الصفحات» مجاني؟

نعم — نص درس «التخطيطات ومكوّنات الصفحات» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Next.js 15 Fullstack (App Router + Server Actions)، انتقل إلى CoddyKit PRO. تتضمن دورة Next.js 15 Fullstack (App Router + Server Actions) 4 دروس في المجموع.

ماذا ستتعلم في «التخطيطات ومكوّنات الصفحات»؟

أتقن إنشاء التخطيطات المتداخلة ومكوّنات الصفحات ضمن بنية App Router لتنظيم واجهة المستخدم تتمرن على Next.js 15 Fullstack (App Router + Server Actions) مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Next.js 15 Fullstack (App Router + Server Actions)؟

لا تُشترط خبرة سابقة. Next.js 15 Fullstack (App Router + Server Actions) على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.

كم من الوقت يستغرق درس «التخطيطات ومكوّنات الصفحات»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Next.js 15 Fullstack (App Router + Server Actions) هذا؟

نعم. كل درس في Next.js 15 Fullstack (App Router + Server Actions) يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. التخطيطات ومكوّنات الصفحات
  2. المسارات الديناميكية والمعاملات
  3. واجهة التحميل والخطأ
  4. مجموعات المسارات والتخطيطات المتداخلة
← العودة إلى Next.js 15 Fullstack (App Router + Server Actions)