<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
Next's event only exposes
preventDefault. Now let me check whether something else intercepts clicks before Link's React handler — e.g. a global click listener in the navigation runtime. - Assistant
Now create the App Router fixture:
- Assistant
For the Pages Router, state must persist across navigations, which upstream achieves by mounting the nav in
_app. Let me check the fixture's_app.tsx: - Assistant
Now the e2e specs:
- Assistant
One failure in
instrumentation-startup.spec.ts— unrelated to Link, but let me verify it's pre-existing and not caused by my_app.tsxchange: - Assistant
All navigation specs pass. Run the full unit test project as a final sweep:
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.