Dev Helpers

Next.js / Catch-all documentation

Optional documentation index

Dev Helpers · April 26, 2026

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

Related articles

Free bin volume

Free storage volume depends on consistent dimensions and units. Derive capacity and usage in the same unit before formatting a human-readable summary.

Draft preview indexing

Draft pages need deliberate indexing metadata. An indexing directive controls crawler intent, while access to unpublished material needs a separate permission check.

Party size allocation

Allocating a party into groups is an integer problem. The remainder determines whether another group is needed and how full it will be.