"use client"; import Link from "next/link"; import { forwardRef, type ComponentProps } from "react"; import { hrefFromLinkTarget, interceptAppNavigation } from "@/lib/app-navigation"; import { noteClientNavigationTarget } from "@/lib/client-navigation-target"; export type AppLinkProps = ComponentProps; /** * In-app link that stays on the client router when this tab's build matches * the running image, and does a document load when it does not. * * Next 16.3.1's own mismatch fallback did not fire on this host after a * deploy (see BUG-967); wrapping the destinations that actually no-op'd is * the self-heal. */ export const AppLink = forwardRef(function AppLink( { onClick, href, ...props }, ref, ) { return ( { onClick?.(event); const target = hrefFromLinkTarget(href); interceptAppNavigation(event, target); // A plain click the client router will take: remember where it goes, // for a page that reads its URL before the router writes it (BUG-1040). if (!event.defaultPrevented && event.button === 0 && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey) { noteClientNavigationTarget(target); } }} {...props} /> ); });