Dev Helpers

Next.js / Product route components

Comparison route shortcut

Dev Helpers · January 16, 2026

A comparison shortcut can encode the chosen items in its destination. Preserve the identifiers needed to reconstruct the same view on refresh.

Worked example

// components/ComparisonRouteShortcut.tsx

import Link from "next/link";

export default function ComparisonRouteShortcut({
  slug = "desk-lamp",
  name = "Desk lamp",
}: { slug?: string; name?: string } = {}) {
  return (
    <Link href={{ pathname: "/compare", query: { item: slug } }}>Compare {name}</Link>
  );
}

Implementation notes

URLs are a contract for sharing state. Validate unknown item IDs and decide how to represent a comparison that no longer exists.

Try it yourself

Copy the link into another tab and verify both selections.

Open the Next.js example →

Editorial date January 16, 2026 · Published December 6, 2026

Related articles

Free bin volume

Free storage volume depends on consistent dimensions and units. Derive capacity and usage in the same unit before formatting a human-readable summary.

Draft preview indexing

Draft pages need deliberate indexing metadata. An indexing directive controls crawler intent, while access to unpublished material needs a separate permission check.

Party size allocation

Allocating a party into groups is an integer problem. The remainder determines whether another group is needed and how full it will be.