Dev Helpers
← Back

Optional documentation index

Place this file at app/docs/[[...parts]]/page.tsx in an App Router project.

Open this example in the interactive library

Source code

// 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>
  );
}