Pages & Layouts Overview
Explore the distinction between pages and layouts, and how they combine to form the UI structure of your Next.js application.
Pages & Layouts Overview is a free Next.js 15 Fullstack (App Router + Server Actions) lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Next.js 15 Fullstack (App Router + Server Actions) learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Welcome to Pages & Layouts
Next.js UI rests on two ideas: Pages and Layouts. This lesson shows what each one is and how they combine to build your interface.
What is a Page?
A Page is a React component that renders the UI for one route. Default-export it from a page.js file and that route gets its own view.
Creating a Simple Page
Here's a basic page.js that renders the home route /. A page is just a default-exported component — nothing more.
// app/page.js
export default function HomePage() {
return (
<h1>Welcome to My App!</h1>
);
}What is a Layout?
A Layout is UI shared across pages — a wrapper that gives consistent structure. Export it from layout.js; it takes a children prop for nested content.
The Root Layout
Every App Router app needs a root layout at app/layout.js. It wraps the whole app, including the html and body tags — the place for global styles and metadata.
// app/layout.js
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
{children}
</body>
</html>
);
}Nested Layouts
Add a layout.js inside any folder for a nested layout. An app/dashboard/layout.js wraps every page under dashboard — unique shared UI per section.
How They Combine
Next.js nests layouts automatically: a page renders inside its parent layout's children, that inside its parent's, all the way up to the root.
Example: A Blog Section
Picture a blog: blog/layout.js gives a shared nav, blog/page.js is the index, and blog/first-post/page.js a post — each nesting upward into the root.
Code: Blog Layout Example
This blog/layout.js wraps every /blog page with a header, nav, and footer — shared chrome that stays consistent across the section.
// app/blog/layout.js
export default function BlogLayout({ children }) {
return (
<div>
<header><h1>My Awesome Blog</h1></header>
<nav>
<a href="/blog">Home</a> | <a href="/blog/archive">Archive</a>
</nav>
<main>{children}</main>
<footer><p>© 2023 CoddyKit Blog</p></footer>
</div>
);
}Code: Blog Page Example
And here's blog/page.js. Its content renders right where {children} sits inside BlogLayout — page slotting into layout.
// app/blog/page.js
export default function BlogHomePage() {
return (
<section>
<h2>Welcome to the Blog Homepage!</h2>
<p>Discover our latest articles and insights.</p>
</section>
);
}Pages vs. Layouts Quiz
Let's check your understanding of Next.js pages and layouts.
Recap: Pages & Layouts
Recap: Pages (page.js) render a route's unique UI, Layouts (layout.js) share UI across routes, and Next.js nests them via children.
Frequently asked questions
Is the “Pages & Layouts Overview” lesson free?
Yes — the full text of “Pages & Layouts Overview” is free to read here on the web, and the Next.js 15 Fullstack (App Router + Server Actions) course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Next.js 15 Fullstack (App Router + Server Actions) course, upgrade to CoddyKit PRO.
What will I learn in “Pages & Layouts Overview”?
Explore the distinction between pages and layouts, and how they combine to form the UI structure of your Next.js application. You practise Next.js 15 Fullstack (App Router + Server Actions) with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Next.js 15 Fullstack (App Router + Server Actions)?
No prior experience is required. Next.js 15 Fullstack (App Router + Server Actions) on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Pages & Layouts Overview” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Next.js 15 Fullstack (App Router + Server Actions) lesson?
Yes. Every Next.js 15 Fullstack (App Router + Server Actions) lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Project Setup & CLI
- File-System Routing Basics
- Pages & Layouts Overview
- Styling Your Next.js App