Root layout and children
A root layout supplies the document shell for a tree of App Router pages. Its children prop is the route UI that Next.js places inside that shell. Put shared document-level markup here, and keep the page responsible for its own main content.
Scope: Next.js 16.x candidate, App Router only, Cache Components disabled, TypeScript unless otherwise labeled. Examples are static source walkthroughs; exact framework patch and build are not verified.
app/layout.tsx
import type { ReactNode } from 'react';import Link from 'next/link';
export default function RootLayout({ children }: { children: ReactNode }) { return ( <html lang="en"> <body> <header><Link href="/">River Books</Link></header> {children} </body> </html> );}Every page under this root is expected to share the River Books header. The value of children changes according to the active route. ReactNode is a TypeScript type for renderable React content; the Link import is introduced in chapter 6 and can be read here as a link to the home page.
Document versus page
The root layout must provide html and body. A page is the leaf UI for a URL; it is not another document shell. Prefer a single main landmark, supplied by the page in this example. Document titles are handled by the framework metadata system, introduced later, rather than manually repeating head elements.
app/page.tsx
export default function Home() { return <main><h1>Welcome to River Books</h1></main>;}The home page displays a header followed by its own main heading. On /catalog the same header can wrap different main content.
Common mistake
Do not omit children or put a second html/body pair in the page. Without children the shared shell does not display its descendant page.
Try it yourself
Add a footer to the root layout and predict the two places where it appears when visiting / and /catalog. Keep only one main landmark on each page.
After this lesson, you should be able to: Compose HTML and body with children; Explain the root wrapper.