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 call ) using or commands. However you don't need to use or before submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted. - Assistant
I'll start by exploring the repository structure and finding the Link component implementation, then compare it with Next.js's
onNavigateAPI. - Assistant
Let me look at the Link shim implementation and the Next.js reference for onNavigate.
- Assistant
There's already a partial
onNavigateimplementation — I'll inspect the click handler and the Next.js source/docs next. - Assistant
I'll read the click-handler section of the Link shim and the Next.js
onNavigateimplementation. - Assistant
There's already an
onNavigateimplementation; I'll compare it with Next.js source and the failing tests. - Assistant
rg is not available, let me use grep.
- Assistant
Let me look at the Next.js linkClicked implementation more carefully, and the vinext tests.
- Assistant
Let me hunt for the Next.js
link-on-navigatetest suite and how vinext wiresnext/link. - Assistant
I'll inspect the rest of the click handler and how Link is aliased into the build.
- Assistant
I'll look for the Next.js e2e test sources and any agent notes that expand on this bug.
- Assistant
I'll fetch the Next.js
link-on-navigatee2e test so we can match its contract exactly. - Assistant
Good, got the test. Let me read it.
- Assistant
Let me look at the shared OnNavigate component and check other subtle differences in Next.js link click handling.
- Assistant
Looking at the test failures more carefully in the agent-created issue: I need to implement the
onNavigateprop support in vinext'snext/linkshim to match Next.js 15+ behavior.First, let me explore the current implementation to understand where to make changes. Let me check the Link component code. The issue mentions looking at
.nextjs-ref/packages/next/src client/link.tsx, but since we're in vinext, I'll look at our own implementation. Let me find where Link is defined.Let me use the shell to explore the codebase. I'll search for Link component files.
Let me check what's in the current directory structure. I should look for the Link implementation.
- Assistant
Checking how Next.js wires onClick vs linkClicked, and reviewing vinext's link tests.
- Assistant
Let me run the existing link/onNavigate tests and compare their coverage with the Next.js e2e suite.
- Assistant
The full suite timed out — I'll check the test setup and run a narrower case.
- Assistant
Let me try running the test with more time.
- Assistant
The suite keeps timing out on start — I'll invoke vitest more directly.
- Assistant
Vitest also hangs. Let me check vite config for test projects.
- Assistant
Maybe vp needs a special setup — I'll try with a longer timeout and check for lock issues.
- Assistant
Interesting - vitest is not installed as a binary. Let me check.
- Assistant
So tests are run via
vp test. Let me try running with a longer timeout. - Assistant
Need to use the full path or pnpm.
- Assistant
Even with 180 seconds timeout it hangs with no output. Something might be wrong with the test environment. Let me try other approaches.
- Assistant
Corepack was hanging on pnpm download — I'll call the vp binary directly.
- Assistant
I'll write a temporary script that exercises
onNavigatethe way the Next.js e2e suite does. - Assistant
I'll check git history for
onNavigateand any remaining gaps versus Next.js. - Assistant
Checking Next.js
isLocalURLand whether vinext misclassifies area URLs as external. - Assistant
I'll check the CI run and any server/RSC Link variants that might drop
onNavigate. - Assistant
I'll try to pull warm details from that CI run on GitHub.
- Assistant
I'll inspect the nextjs-deploy-suite workflow and try to fetch the CI failure logs.
- Assistant
I'll look at how the deploy suite patches Next with vinext.
- Assistant
I'll inspect how e2e-deploy wires vinext into the Next.js suite.
- Assistant
I'll check for any dual/pages-only Link path and how Next.js resolves
next/linkunder RSC. - Assistant
I'll look for deploy-suite reports and try running the Next.js fixture under vinext.
- Assistant
I'll add temporary unit tests covering the full Next.js onNavigate contract and see what fails.
- Assistant
onNavigate works in unit tests; the external
replacegap is real. Next I'll check pages-router navigation and hybrid fixtures for full reloads that would wipe click state. - Assistant
I'll inspect href resolution helpers — a bad absolute URL could keep
onNavigatefrom firing. - Assistant
I'll check how
next/linkis aliased during builds used by the deploy suite. - Assistant
I'll check how Next packages
next/linkacross app vs pages. - Assistant
Checking Next package exports to see how app-dir vs pages Link is chosen.
- Assistant
Let me check how Next.js chooses between app-dir and pages link:
- Assistant
I'll inspect the rest of the Pages Router
linkClickedflow. - Assistant
I'll try downloading the GitHub Actions logs for that failed run.
- Assistant
I'll try to pull logs for one of the failed shards.
- Assistant
I'll check hybrid app/pages handling — that fixture has both routers, which may explain the e2e failures.
- Assistant
I'll check how app-dir Link formats the href passed into
linkClicked. - Assistant
Checking whether
next/linkaliasing is complete, including.jsvariants and optimizeDeps. - Assistant
Let me look at how nextShimMap gets .js variants
- Assistant
I'll extract the nextShimMap construction with Node.
- Assistant
Need more lines to see the rar transform.
- Assistant
Let me find the transform applied to entries:
- Assistant
I'll check how
withBasePathtreats absolute URLs before implementing the replace fix. - Assistant
Checking
normalizePathTrailingSlashon absolute URLs. - Assistant
I'll inspect blog what app-router navigate does for pages-only paths — that may drop SF client state.
- Assistant
I'll try downloading the report artifact without authentication.
- Assistant
Implementing the external-
replacefix to match Next.js, then verifying with the temp tests. - Assistant
I'll fix external
replacehandling and makeonNavigatefire even if URL parsing fails. - Assistant
Checking whether app navigate hard-navigates on pages-router paths in hybrid apps.
- Assistant
I'll inspect hard-navigation decision paths in the browser entry.
- Assistant
Hybrid apps may be routing pages links through the app navigator. I'll check how that decision is made.
- Assistant
I'll look at hybrid build/runtime routing between app and pages paths.
- Assistant
I'll check how Next resolves
next/linkdifferently for app and pages. - Assistant
Let me search for how Next swaps the link for app-dir.
- Assistant
I'll examine hybrid client entry generation.
- Assistant
I'll inspect hybrid SSR/browser hydration for pages routes.
- Assistant
There's
renderPagesFallback- when RSC can't find a route, it falls back to pages rendering. When client-side navigate to a pages route via RSCfetch, the server might return HTML pages response, and...I understand the core issue: theonNavigateprop on<Link>isn't firing in vinext's hybrid setup because the unified Link component defaults to app-router navigation, which bypasses the callback in some cases. - Assistant
I'll look for client-side route matching against the app route manifest.
- Assistant
There's already matchRouteWireWithTrie for prefetch. Let me look at link.tsx prefetch logic and how x it matches routes.
- Assistant
I'll check how to detect whether the pages router is active.
- Assistant
I'll check whether hybrid pages navigation is already supported somewhere.
- Assistant
I'll check the deploy tests manifest for skips related to this suite.
- Assistant
Let me check if link-on-navigate is in deploy-tests-manifest and its skip status.
- Assistant
I'll inspect how hybrid pages fallback renders and hydrates.
- Assistant
Checking hybridCLI build for pages client bundles.
- Assistant
Re-running the reproduction tests and cleaning up.
- Assistant
I'll align the modified-event check with Next.js and clean up the temp test.
- Assistant
I'll make
getAttributeaccess defensive so existing test_mocks won't throw. - Assistant
The replace didn't apply — I'll go to the spot and edit it.
- Assistant
Re-running the link unit tests.
- Assistant
I'll clean temporary files and verify the final diff.
- Assistant
Submitting the change.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.