Skip to main content

App Router Mastery

Nested Layouts and Route Groups

0:00
LearnStep 1/4

Understanding the Layout Hierarchy

Layouts: The Backbone of Next.js App Router

In the App Router, layouts are persistent components that wrap pages and preserve state during navigation. Understanding how they compose is essential for building efficient applications.

The Layout Hierarchy

How Nesting Works

When rendering /dashboard/analytics, Next.js composes:

tsx
Key Insight: Parent layouts DO NOT re-render when navigating between child pages. Only the changed segment re-renders.

Layout Implementation

tsx

Layout vs Template

LayoutTemplate
Persists state between navigationsCreates new instance on every navigation
Does not re-mountRe-mounts on every route change
Use for: sidebars, navbars, shared UIUse for: analytics, animations, per-page effects
tsx