<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
Implementing
onNavigateon<Link>: reviewing the vinext shim and Next.js reference implementation. - Assistant
Adding unit tests to reproduce the issue, then fixing any gaps.
- Assistant
Fixing the external
replacegap and hardeningonNavigatehandling. Unit tests show it fires on the first click; the second click failed becausedefaultPreventedstayed set. - Assistant
Implemented and hardened
<Link onNavigate>to match Next.js behavior.What was wrong
onNavigatewas already wired inlink.tsx, but two gaps caused Deploy Suite failures:- Silent skip — A
try/catcharound the wholeonNavigateblock could swallow URL construction errors and skip the callback while navigation still proceeded. - External
replace— External URLs withreplacedid not calllocation.replace()(Next.js does this inlink.tsxbefore returning).
Changes
packages/vinext/src/shims/link.tsx - Silent skip — A
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.