nextjs - ✅(Solved) Fix Router .push with fragments duplicates when doing client side navigation [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#93126Fetched 2026-04-23 07:21:51
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
cross-referenced ×1issue_type_added ×1labeled ×1subscribed ×1

Fix Action

Fixed

PR fix notes

PR #93132: test: double fragment on navigation

Description (problem / solution / changelog)

Adds a failing e2e for https://github.com/vercel/next.js/issues/93126

Changed files

  • test/e2e/app-dir/navigation/app/hash-cross-path-push/client-component.js (added, +9/-0)
  • test/e2e/app-dir/navigation/app/hash-cross-path-push/destination/page.js (added, +17/-0)
  • test/e2e/app-dir/navigation/app/hash-cross-path-push/page.js (added, +17/-0)
  • test/e2e/app-dir/navigation/navigation.test.ts (modified, +23/-0)

Code Example

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Enterprise
  Available memory (MB): 31925
  Available CPU cores: 24
Binaries:
  Node: 24.7.0
  npm: 11.12.1
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.2.4 // Latest available version is detected (16.2.4).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/beepBoop971/bug-next-js-hash-navigation/tree/main

To Reproduce

  1. Start the application (npm run dev)
  2. Click the button which takes you to route /abc (route changes to /abc#FragmentDynamic
  3. Click the button (change fragment) (route changes to /abc#FragmentDynamic#DifferentFragment)

Current vs. Expected behavior

Following the steps above I expect the route to change to /abc#DifferentFragment as the route we have push is

router.push(/abc#DifferentFragment)

But the previous fragment is still present. Similarly when navigating back and forwards between /abc and home occasionally the fragment #DifferentFragment is repeated

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Enterprise
  Available memory (MB): 31925
  Available CPU cores: 24
Binaries:
  Node: 24.7.0
  npm: 11.12.1
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.2.4 // Latest available version is detected (16.2.4).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Linking and Navigating

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local), Other (Deployed)

Additional context

This started happening after 16.2.0 it was working correctly in 16.1.6

extent analysis

TL;DR

The issue can be fixed by properly handling fragment navigation in Next.js, potentially by using the replace option with router.push or modifying the href attribute.

Guidance

  • Verify that the router.push method is being used correctly, and consider using the replace option to replace the current URL instead of adding a new entry to the browser's history.
  • Check the href attribute of the button that triggers the navigation, and ensure it is not causing the fragment to be appended incorrectly.
  • Review the changes made in Next.js version 16.2.0 and later, and check if there are any updates or workarounds provided for fragment navigation.
  • Test the application with different navigation scenarios to ensure the issue is not specific to a particular route or fragment.

Example

// Example of using replace option with router.push
router.push(`/abc#DifferentFragment`, undefined, { replace: true });

Notes

The issue seems to be specific to Next.js version 16.2.0 and later, and may be related to changes made in the router.push method or fragment navigation handling.

Recommendation

Apply a workaround by using the replace option with router.push or modifying the href attribute, as the root cause of the issue is likely related to the changes made in Next.js version 16.2.0 and later.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING