Dev Helpers
← Back

Family reference breadcrumb

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

Open this example in the interactive library

Source code

// app/species/[id]/page.tsx

import Link from "next/link";

import { notFound } from "next/navigation";

export default async function FamilyReferenceBreadcrumb({
  params,
}: {
  params: Promise<{ id: string }>;
}) {
  const entries = [
    {
      id: "robin",
      name: "American robin",
      group: "Thrush",
      months: [3, 4, 5, 6, 7, 8, 9],
    },
    {
      id: "junco",
      name: "Dark-eyed junco",
      group: "Sparrow",
      months: [1, 2, 3, 10, 11, 12],
    },
  ];
  const { id } = await params;
  const bird = entries.find((b) => b.id === id);
  if (!bird) notFound();
  return (
    <nav aria-label="Bird family">
      <Link href="/species">Species</Link> /{" "}
      <Link href={{ pathname: "/families", query: { name: bird.group } }}>
        {bird.group}
      </Link>{" "}
      / {bird.name}
    </nav>
  );
}