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.
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 statusor 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
Let me start by understanding the repository structure and the issue. The problem is that the
onNavigatecallback prop on<Link>(added in Next.js 15) does not fire. I need to:- Explore the repository structure
- Find the relevant test suite
- Find the Next.js reference implementation
- Find the vinext Link component
- Implement the fix
Let me start by exploring the repo structure.
Assistant
This is a monorepo. Let me look at the vinext package specifically.
Assistant
Let me look for the Link component and the onNavigate-related files.
Assistant
Let me combine these into a single command.
Assistant
Found the relevant files. Let me examine the Link component and the onNavigate references
Assistant
Let me see more of the file, especially the click handler and where onNavigate should be called.
Assistant
Let me find the click handler and the main component.
Assistant
Let me now look at the handleClick function and the full Link component implementation
Assistant
Now let me see the handleClick function in detail.
Assistant
Interesting! The
onNavigatecode already exists in the handler. Let me look at the rest of the file and also check the test suiteAssistant
Now let me look at the test suite and the Next.js reference implementation.
Assistant
The test suite doesn't exist in the repo. Let me look for the test directory structure.
Assistant
Let me search for the Next.js reference implementation and the test files
Assistant
Let me search for the test directories more broadly
Assistant
Let me check the type definitions and the router shim for onNavigate.
Assistant
Let me search for the Next.js reference implementation
Assistant
Let me look at the tests directory for the link-on-navigate tests
Assistant
Let me search for tests related to navigation or link
Assistant
Let me look at the link test file to understand the test structure
Assistant
Let me look at the relevant test sections
Assistant
Let me check the Next.js source in node_modules for the reference implementation
Assistant
Let me look at the Next.js link implementation
Assistant
Let me look at the full linkClicked function in the Next.js reference
Assistant
Let me check the built/dist version of the link component
Assistant
Let me look at the dist file around the onNavigate section
Assistant
Let me look at the full test file for link-navigation to understand the test structure
Assistant
Let me look at the test around line 466-540 in detail
Assistant
Let me look at the full Next.js link.js to understand the complete API
Assistant
Let me run the existing link tests to see their current state
Assistant
Let me try a faster approach - look at the test file and create a reproduction script
Assistant
Let me look at the test around line 466-545 more carefully and also look at the mock setup
Assistant
Let me also check the link.test.ts file
Assistant
Let me search for onNavigate in the Next.js types
Assistant
Let me look at the type definitions.
Assistant
Interesting! So the Next.js
onNavigatetype is simply:typescripttype OnNavigateEventHandler = (event: { preventDefault: () => void; }) => void;It only has
preventDefault. Nourl, nodefaultPrevented, nodestination. The vinext implementation addsurlanddefaultPreventedwhich is a superset, so it should be backward compatible.Now, let me look at the app-dir/link.d.ts too:
Assistant
Let me search for the Next.js test file to understand what it expects
Assistant
Let me check the git history for recent changes to the link component
Assistant
Let me check when onNavigate was first added
Assistant
Let me look at the commit that added onNavigate
Assistant
Let me look at the e2e test files related to navigation
Assistant
Let me look at these test files to understand what onNavigate tests exist.
Assistant
Let me see more of this test and also look at the link-advanced spec.
Assistant
Let me look at the link-advanced spec for onNavigate:
Assistant
Let me look for the Next.js test file in node_modules
Assistant
Let me look at the AGENTS.md file for more context
Assistant
Let me compare the source and dist versions of the link component
Assistant
Let me search for relevant test patterns in the Next.js package
Assistant
Let me look at the App Router link implementation
Assistant
Let me look at the navigation shim for context on the navigation system
Assistant
Let me look at router.ts for onNavigate references
Assistant
Let me look at the router.ts context around line 936
Assistant
Let me look at the full dist file to check if the build is correct
Assistant
Let me look at the dist file's onNavigate section more carefully
Assistant
Let me compare the ESM version of the Next.js link
Assistant
Let me search for "onNavigate" more broadly in the vinext codebase
Assistant
Let me look at the url-utils functions used in the click handler
Assistant
Let me look at those functions.
Assistant
Let me look for any Next.js test fixtures related to onNavigate
Assistant
Let me look at the most recent commits to the link component
Assistant
Let me create a minimal reproduction script to test if onNavigate works
Assistant
Let me check the CI configuration for hints about the failing tests
Assistant
Let me look at the nextjs-deploy-suite workflow
Assistant
Let me look at the link-navigation test more broadly
Assistant
Let me look at the Next.js linkClicked function more carefully to see if I missed something
Assistant
Let me try to run the link-navigation test to see if the onNavigate test passes
Assistant
Let me try running just a single test file with timeout
Assistant
Let me check how tests are run
Assistant
Let me search the Next.js source for other uses of on
Assistant
Let me search for the test file using a
Assistant
Let me look at the navigateClientSide function for onNavigate handling
Assistant
Let me look at the
navigateClientSidefunction signatureAssistant
Let me look at the
navigateClientSidefunctionAssistant
Let me check the git history for when onNavigate was added to the Link component
Assistant
Let me check when onNavigate was first added to the codebase
Assistant
Let me look at the earliest onNavigate commit
Assistant
Let me find when onNavigate was first added to the codebase
Assistant
Let me look at the scripts directory for the nextjs deploy suite scripts
Assistant
Let me look at the deploy suite script
Assistant
Let me look at the e2e-deploy.sh script
Assistant
Let me search for any TODO/FIXME comments related to on
Assistant
Let me check if there's a next.js checkout in the repo
Assistant
Let me do a detailed comparison between the source and dist for the handleClick function
Assistant
Let me check if the App Router link.js has use
Assistant
Let me look at the dispatchNavigateAction function in Next.js for onNavigate handling
Assistant
Let me look at the app-router-instance to see how dispatchNavigateAction works
Assistant
Let me look at the dispatchNavigateAction function
Assistant
Let me check if the dist is up to date with the source
Assistant
Let me check git status to see if there are any uncommitted changes
Assistant
Let me look at the fixture pages for onNavigate tests
Assistant
Let me look at the fixture pages for onNavigate
Assistant
Let me look at the Pages Router fixture too
Assistant
Let me search for onNavigate in all Next.js dist files more broadly
Assistant
Let me check the vite config to understand how the link module is built and served
Assistant
Let me create a minimal reproduction script to test the onNavigate behavior
Assistant
Let me look at the nextjs-deploy-manifest script
Assistant
Based on my thorough analysis, the vinext implementation of
onNavigateIS present in the code but I need to look more carefully at edge cases. Let me examine the fullhandleClickfunction and thenavigateClientSidefunction more carefully for any subtleAssistant
Let me check how next/link is resolved in
Assistant
Now I need to understand the root cause better. Let me look at the Next.js pages router link implementation to understand the expected
onNavigateAPI more precisely, and then compare with vinext's implementation line by line.Assistant
Let me verify the full dist file has the correct onNavigate implementation with no syntax issues
Assistant
Let me check git blame for the handleClick function to understand
Assistant
Let me see the blame for the onNavigate section
Assistant
Let me look at the most recent commits to understand what might have changed
Assistant
Let me look at the commit 0d8d3e3 which refactored router topology
Assistant
Let me check the actual diff for link.tsx in the router refactoring
Assistant
Let me look at the
getNavigationRuntimefunction to understand the new navigation runtimeAssistant
Let me search for any onNavigate test patterns in node_modules
Assistant
Let me check for any next.js reference directories
Assistant
I've done extensive analysis. The
onNavigatecallback IS implemented in the code but I need to make it more robust and add missing features. Let me look at what specific changes are needed by examining the complete Next.js API more closelyAssistant
Let me look at the beginning of the handleClick in the dist file very carefully
Assistant
Based on my thorough analysis of both the vinext implementation and the Next.js reference, I can see that the
onNavigatecallback IS implemented. However, there are important gaps:- The
transitionTypesprop is not supported - The
onNavigateevent shape doesn't exactly match Next.js - The return value of
onNavigateis not used for history control
Let me now implement the fixes. First, let me look at the complete current state of the relevant sections:
- The
Assistant
Let me check if
navigateClientSideacceptstransitionTypesAssistant
Vinext already shims
React.addTransitionType! Let me look at how it worksAssistant
Now I have a clear understanding. Let me implement the fixes. I need to:
- Add
transitionTypesprop support - Call
React.addTransitionTypefor each transition type before App Router navigation - Support
onNavigatereturn value for history replacement mode
Let me start editing:
- Add
Assistant
Now let me edit the file to add
transitionTypessupport and improveonNavigate:Assistant
Now let me update the Link component destructuring to include
transitionTypes:Assistant
Now let me update the destructuring to include
transitionTypes:Assistant
Let me use the replace command instead
Assistant
Now let me update the
handleClickfunction to addtransitionTypessupport. Let me look at the current codeAssistant
Now let me update the App Router navigation section to use
transitionTypesAssistant
Let me use replace instead
Assistant
Now let me also update the
next-shims.d.tstype to match the implementation:Assistant
Let me view the full diff of my
Assistant
I need to fix the
React.addTransitionTypecall. The React namespace might not haveaddTransitionType. Let me use a safer approach - import it directly:Assistant
Let me verify the full diff now
Assistant
Let me look at the existing test for onNavigate more carefully to understand the test environment
Assistant
Let me check the TypeScript compilation
Assistant
Let me look at the basic link click test that succeeds
Assistant
Let me verify how
isAbsoluteOrProtocolRelativeUrlworksAssistant
Let me look at the function to verify it correctly identifies
/targetas non-absolute:Assistant
Let me try to build the vinext package to update the dist with
Assistant
Let me check how to build the package
Assistant
Let me also update the next-shims.d.ts to include transitionTypes
Assistant
Let me update the next-shims.d.ts to add
transitionTypes:Assistant
My changes look good. Let me verify the final diff one more time and submit:
Assistant
Actually, let me also verify the
resolveRelativeHreffunction doesn't have issues with the mocked windowAssistant
Let me verify that the TypeScript compiles cleanly one more time
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.