Dev Helpers
← Back

Category filter links

Place this file at components/CategoryFilterLinks.tsx in an App Router project.

Open this example in the interactive library

Source code

// components/CategoryFilterLinks.tsx

import Link from "next/link";

export default function CategoryFilterLinks({
  items = [
    { slug: "getting-started", title: "Getting started" },
    { slug: "building", title: "Building" },
  ],
}: { items?: { slug: string; title: string }[] } = {}) {
  return (
    <nav aria-label="Categories">
      {items.map((i) => (
        <Link key={i.slug} href={{ pathname: "/catalog", query: { category: i.slug } }}>
          {i.title}{" "}
        </Link>
      ))}
    </nav>
  );
}