- All Courses
- Next.js for Production
- Routing and Layouts in the App Router
- Dynamic segments and route parameters
Dynamic segments and route parameters
Wrapping a folder name in square brackets makes that segment dynamic, and its value arrives as a route parameter on the page and layout below it.
Overview
Turning part of the URL into data
Wrapping a folder name in square brackets makes that segment dynamic, and its value arrives as a route parameter on the page and layout below it. A catch-all segment collects the rest of the path into an array instead of a single value.
For content you already know about at build time, generateStaticParams returns the list of parameter values to pre-render. Anything not in that list is still served — rendered on demand the first time it is requested — unless you explicitly opt out.
A dynamic route will eventually be handed a value that matches nothing. Calling notFound() from the page renders the nearest not-found boundary and returns a real 404 status, which matters for crawlers as much as for users.
In this lesson you will:
- Capture a slug or id from the URL
- Pre-render known paths with generateStaticParams
- Handle a missing record with notFound
Resources
Notes are not saved yet — they clear when you leave this page.
Nested layouts and templates
7m
Route groups and parallel routes
11m