`. Call ONCE at app init in a Next.js host.
*/
export function registerLink(component: ComponentType
): void {
// The registration contract IS the assertion: the host states that its
// component handles the props this shim forwards (`next/link` does). One
// narrow assertion here, instead of `any` on the slot and on this
// signature, which erased the type for every caller.
impl = component as RegisteredLink;
}
const Link = forwardRef(function NextLinkShim(props, ref) {
// Real impl path — registered by the host. Hand off untouched so
// every Next-specific prop (prefetch, replace, scroll, locale…)
// reaches the real component intact.
if (impl) {
const Real = impl;
return ;
}
// Fallback path — plain . Drops Next-only props and reduces
// `UrlObject` href to its pathname.
const {
href,
children,
prefetch: _prefetch,
replace: _replace,
scroll: _scroll,
shallow: _shallow,
passHref: _passHref,
legacyBehavior: _legacyBehavior,
locale: _locale,
...rest
} = props;
const hrefStr = typeof href === 'string' ? href : href?.pathname ? href.pathname : undefined;
return (
{children}
);
});
export default Link;