<Link onNavigate> prop not implemented This issue was created by an agent analysing CI…
- User
<Link onNavigate>prop not implementedThis issue was created by an agent analysing CI failures from the Next.js Deploy Suite (vinext
mainvs Next.jsv16.2.6, 2026-05-20).Problem
The
onNavigatecallback prop on<Link>(added in Next.js 15) does not fire. Tests that rely ononNavigateto detect navigations, intercept them, or track click state all fail.Specific failures include:
onNavigatecallback never fires on click- Click state tracking broken (link thinks it was never clicked)
- History state replacement via
onNavigatereturn value not working
Estimated Impact
~8 test failures.
Affected Test Suites
test/e2e/link-on-navigate-prop/index.test.ts(8 failures)
Recommendation
-
Reproduce first in vinext's own test suite. Add a test with
<Link href="/page" onNavigate={(e) => ...}>and verify the callback fires on click. Confirm it does not. -
Study the Next.js implementation. Search
.nextjs-ref/packages/next/src/client/link.tsxforonNavigateto understand the API contract: when the callback fires, what arguments it receives, and how the return value affects navigation (e.g., preventing default, replacing history state). -
Implement
onNavigatein thenext/linkshim. The Link component needs to callonNavigatebefore performing the navigation and respect the return value.
Interface
No new interfaces are introduced.
- Assistant
I'll implement
onNavigateon the Link shim. First I'll review the current implementation and how Next.js handles it. - Assistant
Let me add a focused test and trace the click handler to see what's actually broken.
- Assistant
E2E passes for the basic case. Next I'll port the full Next.js
link-on-navigate-propsuite to find any remaining gaps. - Assistant
Implementation exists but has parity gaps vs Next.js. I'll fix external-link
replacehandling, align click interception, and add tests for the missing cases. - Assistant
onNavigatewas already wired inlink.tsx, but it didn’t fully match Next.js click handling. I aligned it with Next.jslinkClickedand added tests for the deploy-suite cases.Changes
packages/vinext/src/shims/link.tsx- Click flow matches Next.js (
packages/next/src/client/app-dir/link.tsx):- Download links and modified clicks (modifiers, , middle mouse) return before
- Click flow matches Next.js (
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.