ISSUE DESCRIPTION <Link onNavigate> prop not implemented This issue was created by an…
- User
ISSUE DESCRIPTION
<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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /vinext, current file: none) bash-$
- Assistant
I'll start by exploring the repository structure and locating the Link component implementation, as well as the Next.js reference for
onNavigate. - Assistant
Let me examine the Link shim and the Next.js reference for
onNavigate. - Assistant
There's already a type for
onNavigate. I'll check how it's used in the click handler and compare with Next.js. - Assistant
rg is not available, let me use grep.
- Assistant
There's already some
onNavigatecode. I'll inspect the click handler and Next.js's app-dir Link implementation next. - Assistant
I'll inspect Next.js's full
onNavigatecontract — especially event shape and return-value handling. - Assistant
Let me look up Next.js tests and docs for the exact
onNavigateAPI contract. - Assistant
Let me look at the OnNavigateEventHandler type and the next.js deploy suite test for link-on-navigate-prop. Also check the existing tests in the vinext repo more carefully.
- Assistant
I'll read the vinext
onNavigatetests and fetch the Next.js e2e suite that is failing. - Assistant
I'll dig into known issues, check external
replacehandling, and pull the Next.js test fixtures. - Assistant
I'll fetch the fixture pages and run the existing unit tests for link navigation.
- Assistant
Let me get the OnNavigate.tsx fixture content and also look at git log for the link.tsx to see if onNavigate was recently added butbroken.
- Assistant
I'll inspect Next.js pages-router
linkClickedand how vinext wiresnext/link, then run the onNavigate unit tests. - Assistant
I'll check URL helpers and whether something could skip the
onNavigatecall. - Assistant
I'll inspect the compiled dist Link and run a focused unit test.
- Assistant
Vitest is timing out — I'll try a more targeted run.
- Assistant
I'll check for a server-side Link and other code paths that mangeldrop
onNavigate. - Assistant
I'll check the referenced CI run and look for gaps against the Next.js e2e cases.
- Assistant
I'll pull CI logs for the onNavigate failures and compare with when the feature landed.
- Assistant
I'll fetch the failed job logs for the link-on-navigate suite.
- Assistant
Interesting, no failed jobs? Maybe conclusion is different. Let me list all job conclusions.
- Assistant
python3 might not exist?
- Assistant
I'll download failed job logs and search for the on-navigate failures.
- Assistant
I'll run the existing onNavigate e2e tests to see current behavior.
- Assistant
I'll inspect the Next.js deploy suite workflow andowca how it patches Link.
- Assistant
I'll check whether the plugin points at src or dist for shims.
- Assistant
const shimsDir = path.resolve(__dirname, "shims"); - Assistant
I'll inspect how vinext is injected into the Next.js deploy test apps.
- Assistant
I'll check the Next.js fixture layout structure.
- Assistant
I'll check how pages-router wraps OnNavigate.
- Assistant
Let me get _app.tsx content
- Assistant
I'll write a focused temporary script that exercises the full
onNavigatecontract. - Assistant
I'll run a single unit test with a strict timeout.
- Assistant
Even a single test hangs. Something wrong with the test environment. Let me check vite config.
- Assistant
Corepack was hanging on pnpm download — I'll invoke vitest from node_modules instead.
- Assistant
Only vp is available. Corepack was trying to download pnpm. Let me try vp directly.
- Assistant
I'll add a temporary unit test file covering the full onNavigate contract and run it.
- Assistant
I'll create a temporary test file covering onNavigate scenarios.
- Assistant
I'll reuse the existing link-navigation test helpers зе for a cleaner repro.
- Assistant
I'll rewrite the temp test to match the existing mock harness.
- Assistant
I'll check whether locale handling mutates external URLs before implementing the fix.
- Assistant
Implementing the missing external-link
replacehandling to match Next.js, then verifying with the repro tests. - Assistant
I'll update external-link handling to call
location.replacewhenreplaceis set. - Assistant
I'll re-run the repro test and check for a server-side Link path.
- Assistant
I'll check how Link chooses app vs pages navigation in hybrid setups.
- Assistant
I'll rebuild the package, remove the temp test, and run the linked unit tests.
- Assistant
I'll confirm the dist includes the fix and re-run the link-navigation tests.
- Assistant
I'll set up a quick local e2e fixture to validate onNavigate end-to-end.
- Assistant
I'll run the existing onNavigate e2e tests against app-router and pages-router.
- Assistant
I'll review the final diff and confirm only the intended source change remains.
- Assistant
I'll check whether dist is tracked and whether any other chicken onNavigate gaps remain.
- Assistant
Let me get the onNavigate docs section
- Assistant
I'll harden the onNavigate call so URL parse failures can't skip the callback.
- Assistant
I'll re-run the unit tests and a focused temporary onNavigate check.
- Assistant
I'll rewrite the temp test file cleanly and run it.
- Assistant
I'll write a clean temp test with Node and run it.
- Assistant
I'll drop the flaky temp harness and re-run the existing link-navigation suite.
- Assistant
All tests pass. Rebuilding once more incase, then submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →