Skip to content
Dashboard

Next.js Layouts RFC in 5 minutes

VP of Developer Experience

Link to headingCreating Routes

app/page.js
export default function Page() {
return <h1>Hello, Next.js!</h1>
}

A new Page inside the app directory.

Each route segment is mapped to a corresponding segment in a URL path.
Each route segment is mapped to a corresponding segment in a URL path.

Link to headingCreating Layouts

Creating routes using pages and layouts.
Creating routes using pages and layouts.
app/layout.js
export default function RootLayout({ children }) {
return (
<html>
<head>
<title>Next.js Layouts RFC in 5 Minutes</title>
</head>
<body>{children}</body>
</html>
);
}

Root layout inside the app directory.

<html>
<head>
<title>Next.js Layouts RFC in 5 Minutes</title>
</head>
<body>
<h1>Hello, Next.js!</h1>
</body>
</html>

The rendered HTML output from the root layout and page.

Link to headingSharing Layouts

app/blog/page.js
export default function BlogPage() {
return <h1>Blog Posts</h1>
}

Blog page inside the app directory.

<html>
<head>
<title>Next.js Layouts RFC in 5 Minutes</title>
</head>
<body>
<h1>Blog Posts</h1>
</body>
</html>

The rendered HTML output from the root layout and blog page.

app/blog/layout.js
export default function BlogLayout({ children }) {
return (
<>
<aside>
<nav>...</nav>
</aside>
{children}
</>
)
}

Layout specific to the blog route segment.

<html>
<head>
<title>Next.js Layouts RFC in 5 Minutes</title>
</head>
<body>
<aside>
<nav>...</nav>
</aside>
<h1>Blog Posts</h1>
</body>
</html>

The rendered HTML output from the root layout, blog layout, and blog page.

app/blog/[slug]/page.js
export default function IndividualBlogPost() {
return (
<main>
<h1>Routing with Next.js</h1>
<p>Lorem ipsum dolor sit amet</p>
</main>
)
}

Page for a specific blog post, using a dynamic route.

<html>
<head>
<title>Next.js Layouts RFC in 5 Minutes</title>
</head>
<body>
<aside>
<nav>...</nav>
</aside>
<main>
<h1>Routing with Next.js</h1>
<p>Lorem ipsum dolor sit amet</p>
</main>
</body>
</html>

Layout for the individual blog post page with a dynamic route.

Link to headingLoading & Error Boundaries

The Next.js Loading UI creates a React Suspense boundary.
The Next.js Loading UI creates a React Suspense boundary.
The Next.js Error UI creates a React error boundary.
The Next.js Error UI creates a React error boundary.

Link to headingRoute Groups

You can exclude routes from layouts using route groups.
You can exclude routes from layouts using route groups.

Link to headingSummary