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