Dev Helpers
← Back

Linked product tile

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

Open this example in the interactive library

Source code

// components/LinkedProductTile.tsx

import Link from "next/link";

export default function LinkedProductTile({
  slug = "desk-lamp",
  name = "Desk lamp",
  price = 64,
}: { slug?: string; name?: string; price?: number } = {}) {
  return (
    <article>
      <h2>
        <Link href={"/products/" + encodeURIComponent(slug)}>{name}</Link>
      </h2>
      <data value={price}>${price.toFixed(2)}</data>
    </article>
  );
}