Catch-all segments
Catch-all segments match multiple path components. Use [...parts] for one or more components and [[...parts]] when the same page should also handle the parent URL. Both capture the components as an array when present.
Scope: Next.js 16.x candidate, App Router only, Cache Components disabled, TypeScript unless otherwise labeled. Examples are static source walkthroughs; exact framework patch and build are not verified.
app/guide/[[...parts]]/page.tsx
export default async function GuidePage({ params }: { params: Promise<{ parts?: string[] }>;}) { const { parts } = await params; const trail = parts ?? []; return <main><h1>{trail.length ? trail.join(' / ') : 'Guide home'}</h1></main>;}/guide displays Guide home. /guide/start displays start. /guide/start/setup displays start / setup. An omitted optional capture is undefined, so the nullish fallback creates an empty array.
Compare required and optional matches
A required catch-all route app/guide/[...parts]/page.tsx does not match /guide on its own. It can be paired with a separate app/guide/page.tsx. Do not define an optional catch-all and an index page that both own /guide. A catch-all is appropriate for a document hierarchy; use an ordinary [slug] for a single record identifier.
Route expectations (not a running router)
/guide required: no match optional: undefined/guide/start required: ["start"] optional: ["start"]/guide/start/setup required: ["start","setup"] optional: ["start","setup"]The table assumes each route design is considered separately and no competing route or rewrite exists.
Common mistake
Do not assume an optional capture is always an empty array, or join it into a filesystem path without validating an allowed logical document identifier.
Try it yourself
Choose required or optional catch-all for a documentation section whose homepage is a separate component. Explain how your chosen tree avoids a duplicate route.
After this lesson, you should be able to: Predict array parameters; Compare required and optional catch-all.
Further reading: Dynamic and catch-all parameter shapes.