Open this example in the interactive library
Source code
"use client";
// components/RoutePathBreadcrumb.tsx
import Link from "next/link";
import { usePathname } from "next/navigation";
export default function RoutePathBreadcrumb({
href = "/studio",
label = "Studio",
}: { href?: string; label?: string } = {}) {
const parts = usePathname().split("/").filter(Boolean);
return (
<nav aria-label="Breadcrumb">
<Link href="/">Home</Link>
{parts.map((p, i) => (
<span key={i}>
{" "}
/{" "}
<Link
href={"/" + parts.slice(0, i + 1).join("/")}
aria-current={i === parts.length - 1 ? "page" : undefined}
>
{p}
</Link>
</span>
))}
</nav>
);
}
