mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #468] [MERGED] fix: emit hashChangeStart/Complete and beforeHistoryChange router events #594
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#594
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/468
Author: @NathanDrake2406
Created: 3/11/2026
Status: ✅ Merged
Merged: 3/12/2026
Merged by: @james-elicx
Base:
main← Head:fix/router-hash-beforehistorychange-events📝 Commits (7)
033e1d4fix: emit hashChangeStart/Complete and beforeHistoryChange events5336ce3fix: emit full URL in hash change events, not just fragment0276b52fix: handle hash-only popstate and address review feedback3232c85fix: pass { shallow } to routeChangeError, add goForward hash teste318312fix: include hash in popstate beforeHistoryChange URL, stabilize forward testd05e0acfix: strip basePath from full-path hash URLs, include hash in popstate event URLsacce8f8fix: update _lastPathnameAndSearch after beforePopState check📊 Changes
3 files changed (+244 additions, -15 deletions)
View changed files
📝
packages/vinext/src/shims/router.ts(+96 -15)📝
tests/e2e/pages-router/router-events.spec.ts(+123 -0)📝
tests/fixtures/pages-basic/pages/router-events-test.tsx(+25 -0)📄 Description
Summary
router.push("#section")) now emitshashChangeStartbefore andhashChangeCompleteafter, matching Next.js behavior. Previously emitted zero events.beforeHistoryChangenow fires betweenrouteChangeStartandhistory.pushState/replaceStateon normal navigation. Previously never emitted.{ shallow }as the second argument, matching the Next.js contract.useRouter().push,useRouter().replace,Router.push,Router.replace, and the popstate handler.Ported from Next.js event contract documented in:
docs/02-pages/04-api-reference/03-functions/use-router.mdxTest plan
beforeHistoryChangefires betweenrouteChangeStartandrouteChangeCompleteonrouter.push()hashChangeStartandhashChangeCompletefire on hash-onlyrouter.push("#section")hashChangeStartfires beforehashChangeCompletehashChangeStart/Completefire onrouter.replace("#section")routeChangeStart/routeChangeComplete🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.