Dev Helpers
← Back

Product variant route links

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

Open this example in the interactive library

Source code

// components/ProductVariantRouteLinks.tsx

import Link from "next/link";

export default function ProductVariantRouteLinks({
  slug = "desk-lamp",
}: { slug?: string } = {}) {
  return (
    <nav aria-label="Finish">
      {["copper", "black"].map((f) => (
        <Link
          key={f}
          href={{
            pathname: "/products/" + encodeURIComponent(slug),
            query: { finish: f },
          }}
          scroll={false}
        >
          {f}{" "}
        </Link>
      ))}
    </nav>
  );
}