<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
The shim looks like it should handle most of this already. Let me check the git history — the CI run is from 2026-05-20, and the onNavigate code may be newer.
- Assistant
Let me reproduce this in vinext's own test environment. First, look at the existing fixtures and how e2e tests run.
- Assistant
Now let me set up a reproduction. I'll add fixture pages mirroring the Next.js test, then a spec.
- Assistant
Let me create fixture pages mirroring the upstream test. First the shared component for the App Router fixture:
- Assistant
Now the e2e specs. Let me check conventions in existing specs first:
- Assistant
Dev server works. Now run the spec against it:
- Assistant
All failing at hydration wait — the page itself may be erroring. Let me inspect:
- Assistant
The vinext package dist is stale. Build it, then restart the dev server:
- Assistant
The file exists now — likely a stale cache in the dev server. Restart cleanly:
- Assistant
Multiple stale dev servers are fighting over the port. Kill them all and start fresh:
- Assistant
All dead. Now let Playwright manage the server:
- Assistant
While that runs, let me look at the URL helpers to implement the fix precisely:
- Assistant
All 14 pass. Now add a unit test for the external+
replacebehavior alongside the existing Link unit tests: - Assistant
Waiting on the full app-router e2e run and the repo typecheck — both are running in the background and will report back shortly.
- Assistant
Typecheck passed (exit 0). Still waiting on the app-router e2e suite.
- Assistant
Exit code 0 came from the pipe tail, and stdout is empty — not trustworthy. Rerun with output written directly to a file:
- Assistant
All 5 instrumentation tests pass on a fresh server — that failure was a reused-dev-server artifact, unrelated to this change. Everything is green.
Summary
Diagnosis: I ported the full Next.js
test/e2e/link-on-navigate-propsuite into vinext's e2e tests and ran it against both routers. Contrary to the issue title,onNavigatedoes fire — 6 of 7 scenarios passed out of the box (callback firing, click tracking, interception, modifier-key/download//external exclusions). The one real gap: , because the Link shim returned early for external URLs without honoring .
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.