You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by rajput-hemant December 22, 2025
Hi 👋
I’m running into an issue with nuqs where the URL state seems to stay stale when cacheComponents: true is enabled in next.config.js.
Context
I have a task list → task edit flow where:
The selected taskId is stored in the URL using nuqs
When clicking Edit, I navigate to a task form page
The form is prefilled based on the taskId from nuqs state
This works fine until a previously edited task is deleted.
Problem
When cacheComponents: true is enabled:
nuqs continues to return the previous taskId
Even after navigating back to the list and selecting a different task
This causes the app to try fetching a deleted task, resulting in an error
This behavior does not occur when cacheComponents is disabled.
I’m not sure if this is:
A bug in nuqs
An interaction issue with Next.js component caching
Or expected behavior, and I need to explicitly opt out of caching nuqs state
Expected behavior
nuqs state should reflect the latest URL param
When navigating back and selecting a new task, the old taskId should not be reused
Deleting a task should not cause stale URL state to persist
Actual behavior
nuqs returns a stale taskId
App attempts to fetch a task that no longer exists
This only happens when cacheComponents: true is enabled
Steps to reproduce
Enable cacheComponents: true in next.config.js
Open the task list page
Click Edit on Task A
You are navigated to the edit form
Form is prefilled correctly
nuqs state contains taskId = A
Navigate back to the task list
Delete Task A
Click Edit on Task B
❌ App still reads taskId = A from nuqs
❌ Fetch fails because Task A no longer exists
Reproduction sandbox
I’ve created a minimal CodeSandbox with everything needed to reproduce the issue:
Discussed in #1272
Originally posted by rajput-hemant December 22, 2025
Hi 👋
I’m running into an issue with nuqs where the URL state seems to stay stale when
cacheComponents: trueis enabled innext.config.js.Context
I have a task list → task edit flow where:
taskIdis stored in the URL using nuqstaskIdfrom nuqs stateThis works fine until a previously edited task is deleted.
Problem
When
cacheComponents: trueis enabled:This behavior does not occur when
cacheComponentsis disabled.I’m not sure if this is:
Expected behavior
taskIdshould not be reusedActual behavior
taskIdcacheComponents: trueis enabledSteps to reproduce
Enable
cacheComponents: trueinnext.config.jsOpen the task list page
Click Edit on Task A
taskId = ANavigate back to the task list
Delete Task A
Click Edit on Task B
❌ App still reads
taskId = Afrom nuqs❌ Fetch fails because Task A no longer exists
Reproduction sandbox
I’ve created a minimal CodeSandbox with everything needed to reproduce the issue:
👉 https://codesandbox.io/p/devbox/32lkt4
Questions
Is this behavior expected when using
cacheComponents: true?If yes, what’s the recommended way to:
If not expected, I’m happy to raise an issue.
Thanks in advance 🙏
Appreciate all the work on nuqs — it’s been great otherwise!
Screen.Recording.2025-12-22.at.9.43.34.PM.mov