Dev Helpers
← Back

Bounded route depth

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

import { notFound } from "next/navigation";

export default async function BoundedRouteDepth({
  params,
}: {
  params: Promise<{ parts?: string[] }>;
}) {
  const { parts = [] } = await params;
  if (parts.length > 3) notFound();
  return (
    <main>
      <h1>Documentation</h1>
      <p>{parts.join(" → ") || "Index"}</p>
    </main>
  );
}