Loading Depth Study
Preparing your workspace
Dynamic route segments allow one page structure to handle many related URLs using parameters from the route.
Dynamic routes use folder names such as [id] or [slug] to capture values from the URL. This is useful for pages such as /courses/react, /courses/javascript, or /users/123. The route parameter can be used to load the corresponding resource from a database or API. Nested dynamic segments can represent more detailed resource relationships.
A course platform can use /courses/[slug] to render every course from the same page structure.
app/courses/[slug]/page.tsx
export default async function CoursePage({
params
}: {
params: Promise<{ slug: string }>
}) {
const { slug } = await params;
return <h1>Course: {slug}</h1>;
}Visiting /courses/react displays 'Course: react'.