Create a Root Layout in Next.js
📖 Scenario: You are building a simple website using Next.js. You want to create a root layout that wraps all pages with a consistent header and footer.
🎯 Goal: Build a root layout component in Next.js that includes a <header> with a site title, a <main> area for page content, and a <footer> with copyright text.
📋 What You'll Learn
Create a root layout component named
RootLayout in app/layout.tsxUse semantic HTML elements:
<html>, <body>, <header>, <main>, and <footer>Include a
<header> with the text My Next.js SiteRender the children inside the
<main> elementAdd a
<footer> with the text © 2024 My Next.js SiteExport the
RootLayout as the default export💡 Why This Matters
🌍 Real World
Root layouts in Next.js provide a consistent structure and styling for all pages in a website or app.
💼 Career
Understanding root layouts is essential for building scalable Next.js applications and working with the App Router.
Progress0 / 4 steps