What is the difference between [slug] and [...slug]?

[slug] matches exactly one URL segment and gives a string; [...slug] matches one or more segments and gives an array of strings.

Side by side

URLapp/blog/[slug]app/blog/[...slug]
/blogno matchno match
/blog/hello"hello"["hello"]
/blog/2026/11/hellono match (404)["2026", "11", "hello"]

A third form, [[...slug]] (optional catch-all), also matches /blog with slug undefined.

When to use each

  • [slug] for a resource identified by one value: a post, a user profile, a product ID. It is the most common and easiest to type.
  • [...slug] when the depth varies: docs trees, nested categories, CMS-driven paths, or proxy routes.

Things to remember

  • Both are Promise-wrapped in params and must be awaited.
  • generateStaticParams returns { slug: "hello" } for [slug] and { slug: ["2026", "hello"] } for [...slug].
  • You cannot have [slug] and [...slug] as siblings at the same level, because they would be ambiguous for single-segment URLs.
  • Catch-all must be the final segment of the route.

Code example

tsx
1// app/blog/[slug]/page.tsx -> /blog/hello
2export default async function Post({ params }: PageProps<"/blog/[slug]">) {
3 const { slug } = await params; // "hello"
4 return <h1>Post: {slug}</h1>;
5}
6
7// app/docs/[...slug]/page.tsx -> /docs/guides/routing
8export async function DocsPage({ params }: PageProps<"/docs/[...slug]">) {
9 const { slug } = await params; // ["guides", "routing"]
10 return <h1>{slug.join(" › ")}</h1>;
11}
12
13// generateStaticParams shapes differ
14export async function generateStaticParams() {
15 return [
16 { slug: ["guides", "routing"] }, // for [...slug]
17 // { slug: "hello" } // for [slug]
18 ];
19}

Practice this question

Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the Next.js set.

Open in study app