Next.js information (obtained by running next info):
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Pro
Available memory (MB): 32458
Available CPU cores: 20
Binaries:
Node: 20.9.0
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 14.2.14 // Latest available version is detected (14.2.14).
eslint-config-next: 14.2.14
react: 18.3.1
react-dom: 18.3.1
typescript: 5.0.4
Next.js Config:
output: standalone
Are you using:
✅ The app router
❌ The pages router
❌ The basePath option in your Next.js config
❌ The experimental windowHistorySupport flag in your Next.js config
Description
When using next-usequerystate with the app router in a Next.js project, the URL gets duplicated with the anchor multiple times when updating query parameters. For example, when navigating to /course/scratch#signup and then updating the query state with useQueryState, the URL appends the anchor #signup again and again, resulting in something like:
Context
What's your version of
nuqs
?Next.js information (obtained by running
next info
):Are you using:
basePath
option in your Next.js configwindowHistorySupport
flag in your Next.js configDescription
When using
next-usequerystate
with the app router in a Next.js project, the URL gets duplicated with the anchor multiple times when updating query parameters. For example, when navigating to/course/scratch#signup
and then updating the query state withuseQueryState
, the URL appends the anchor#signup
again and again, resulting in something like:I expected
useQueryState
to update the query parameters without duplicating the anchor in the URL.Reproduction
Steps to reproduce the behavior:
/course/scratch#signup
.useQueryState
to update the query parameters (e.g., settinglocation
orgroup
).#signup
anchors.Example code:
Expected behavior:
#signup
), and query parameters should be updated correctly.Actual behavior:
#signup
) is duplicated multiple times in the URL.