<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
Now the specs:
- Assistant
Now let's run the new specs to reproduce. Starting with the App Router project:
- Assistant
Absolute URLs pass through untouched, so
fullHrefequals the rendered external href. Now the fix: - Assistant
Now add unit test coverage for the external +
replacepath intests/link-navigation.test.ts: - Assistant
Pages Router suite: 94 passed. Now the app-router side:
- Assistant
Now a full app-router regression run since
link.tsxis used everywhere: - Assistant
While that runs, let me review the final diff:
- Assistant
The diff is clean. Waiting on the full app-router suite:
- Assistant
The suite is still building its dev server. I'll wait for the background task notifications.
- Assistant
Knip is clean. Waiting for the app-router suite to complete.
- Assistant
The run pipes through
tail -20, so output only appears at completion. The process is alive — waiting for the completion notification. - Assistant
Exit 0 but empty output — suspicious. Re-running in foreground to get a definitive result:
- Assistant
The environment is hitting fork limits from stale dev servers. Let me clean those up:
- Assistant
They're zombies (state Z) — already dead, just unreaped, and not consuming threads. Let me see what's actually alive:
- Assistant
While that runs, let me save useful environment knowledge to memory:
- Assistant
Playwright is still running (the wrapper shell died but the test process survived). Monitoring the log for the final summary:
- Assistant
All done. The task is complete and fully verified.
Summary
The issue claimed
<Link onNavigate>was "not implemented" — that turned out to be partly stale: the callback machinery already existed in the shim (added in #483). Following the issue's own recommendation, I ported the entire upstreamtest/e2e/link-on-navigate-propsuite into vinext's e2e suite first, which pinpointed the actual remaining contract gaps. - Assistant
That's a late notification from one of the earlier watchers, confirming the same final result: 386 passed. Nothing further to act on — the implementation, tests, and full verification are complete as summarized above.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.