-
-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Broken in [email protected] #481
Comments
Thanks for your report. I'm not sure what you mean by "broken", since all tests pass on 14.1.0 (and the docs webapp also runs 14.1.0 and works fine).
This is indeed one limitation that I would like to address in a future release, which may require a big rewrite of the parsers. If you have some feedback on a good API for this, I'd love to discuss more about it. |
Sorry, I realized I wasn't clear at first and edited the description 🙈 |
This comment was marked as off-topic.
This comment was marked as off-topic.
Could it be that the internal state is updated immediately, and useSearchParams lags behind when the URL is actually updated, because of the throttle/defer mechanism? It's a genuine source of issues that I need to address in the docs. I could add an e2e test for this, useSearchParams should be eventually consistent with the query state, when the promise returned by setState resolves. |
I ran the test suite with setting the shallow history state to The initial idea in maintaining the history state was to be as transparent as possible while Next.js didn't have proper shallow routing support (ie: maintaining the internal router state in the history state). I'll have to run some more tests of the impact of setting a Edit: as expected, this breaks with older versions of Next.js: https://github.com/47ng/nuqs/actions/runs/7731026896 |
Noting that I tried to migrate to nuqs recently from a home grown frankenstein, and ran into this bug, so I couldn't proceed. On Next 14.1.0 with latest nuqs, my useSearchParams consumers are not reacting/triggering to query string changes made via nuqs |
Yep, same issue here, unfortunately renders it pretty useless for me. @franky47 happy to help you if I can, really appreciate the effort in this lib over the past few days. |
Thank you all for the feedback, it's been very helpful. I have a fix in the pipeline that maintains compatibility with older versions of Next.js. I'm not a big fan of doing version comparisons in lib code, so this will probably mean that v2.0.0 will only support |
🎉 This issue has been resolved in version 1.16.1-beta.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This issue has been resolved in version 1.16.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Yeah. In our library, before updating to next 14.1.0 enabled
Sounds like a good decision! Nice work on fixing this so fast @franky47 👍 |
Thank you @franky47 ! |
Context
What's your version of
nuqs
?1.15.4
(current latest)Are you using:
basePath
option in your Next.js configwindowHistorySupport
flag in your Next.js configDescription
In next 14.1.0,
windowHistorySupport
is enabled by default:vercel/next.js#60557
And according to the docs, the call to
history.pushState
orhistory.replaceState
has to be withstate = null
, like so:window.history.pushState(null, '', params.toString())
/window.history.pushState(null, '', params.toString())
Current version passes
state = history.state
:nuqs/packages/nuqs/src/update-queue.ts
Lines 183 to 192 in 25356b8
That causes any
useSearchParams
to not be reactive to calls made vianuqs
.Side node:
In my company we have a similar package to
nuqs
; I've tested passingstate = null
and it worked for us.One thing that made the migration painful was that
nuqs
doesn't handleURLSearchParam
native arrays (.append
and.getAll
). So we ended up deciding to keep our current solution, as it was easier to just fix it.The text was updated successfully, but these errors were encountered: