Dynamic route segments
A dynamic segment lets one route file generate many pages from data. Wrap a
folder name in square brackets to create one. For example,
app/blog/[slug]/page.tsx matches /blog/hello-world, /blog/second-post, and
so on, with slug holding the varying part of the URL.
The page receives the segment values through its params prop. In Next.js
16, params is a Promise, and synchronous access has been removed — you
must await it:
// app/blog/[slug]/page.tsx
export default async function BlogPostPage({ params }: { params: Promise<{ slug: string }> }) {
const { slug } = await params;
const post = await getPost(slug);
return <h1>{post.title}</h1>;
}
The page is an async function, await params resolves the segment value, and
then you use it to fetch the data for that page. Nested layouts inside the
dynamic segment can read the same params prop.
You are about to answer a short quiz on [slug] and async params.