layout.tsx
The special file that wraps a segment and all its children in shared UI that stays mounted while you navigate between them.
In more detail
Layouts receive the child page or layout as children. Because they do not re-render on navigation, their state and fetched data survive route changes, but they also cannot read the current searchParams. Layouts nest: a parent layout wraps every child layout below it.
Related terms
- root layout — The required top-level layout that wraps every route and must render the html and body tags.
- nested layout — A layout inside a subfolder, which wraps only that section and is itself wrapped by the layouts above it.
- template.tsx — A special file like layout.tsx that wraps its children but is created fresh on every navigation, so its state resets.
Taught in
- Client Components: use client & Hydration Models — Next.js 15 & Modern App Router Architecture
- Root & Nested Layouts: State Preservation Semantics — Next.js 15 & Modern App Router Architecture
- Templates vs Layouts: Remounting & Page Transitions — Next.js 15 & Modern App Router Architecture
- Route Groups & Private Folders: Modular Structures — Next.js 15 & Modern App Router Architecture
- Error Boundaries: Nested error.tsx & Reset Logic — Next.js 15 & Modern App Router Architecture
- Async Data Fetching: Parallel Requests & Preloading — Next.js 15 & Modern App Router Architecture