Skip to content

useParams is not updating after window.history.pushState (shallow routing) in Next.js #80528

Open
@dBianchii

Description

@dBianchii

Link to the code that reproduces this issue

https://github.com/dBianchii/shallow-routing-bug

To Reproduce

Use my deployed version: https://shallow-routing-bug.vercel.app/tab-9141.

OR:

  1. Run project in dev mode
  2. Click on the button to trigger a redirect to another tab with shallow routing, as described in here: https://nextjs.org/docs/app/guides/single-page-applications#shallow-routing-on-the-client
  3. Notice the new URL. Then notice how the tab state from useParams hasn't changed.
  4. Reload the page manually and watch the useParams hook update

Current vs. Expected behavior

useParams is not updating after calling window.history.replaceState, making it impossible to shallow route to a new param. This is a very common use case for changing tabs for example

I expect useParams to re-run or update when shallow routing with window.history.replaceState

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.5.0: Tue Apr 22 19:53:27 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6041
  Available memory (MB): 24576
  Available CPU cores: 12
Binaries:
  Node: 22.15.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.11.1
Relevant Packages:
  next: 15.3.3 // Latest available version is detected (15.3.3).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: N/A
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), Vercel (Deployed), next start (local), Other (Deployed)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Linking and NavigatingRelated to Next.js linking (e.g., <Link>) and navigation.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions