An optional catch-all can match both a section root and a nested path. The root case needs a useful page when the parameter is absent.
Worked example
// app/docs/[[...parts]]/page.tsx
export default async function OptionalDocumentationIndex({
params,
}: {
params: Promise<{ parts?: string[] }>;
}) {
const { parts = [] } = await params;
return (
<main>
<h1>{parts.at(-1) ?? "Documentation home"}</h1>
<p>{parts.length ? "Reading a topic" : "Choose a topic to get started."}</p>
</main>
);
}Implementation notes
Optional path parameters can distinguish a missing group from an empty array. Normalize them once before using them as lookup keys.
Try it yourself
Load the documentation root, a single section and a two-segment path.
Open the Next.js example →Editorial date April 26, 2026 · Published December 6, 2026