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
This thread was started because of answers coming from #70574. There's no clear answer if/how shallow searchParams are/can be supported without the <Suspense> wrapper.
Goals
Allow for CSR listening on searchparams changes and state retrieval.
Prevent unnecessary streaming when checking for exclusive client-side searchParams.
When unnecessary streaming is prevented - SSR performance should be improved by default.
Non-Goals
No response
Background
In the app router it is currently not possible to listen for query parameters purely on the client-side without opting in to Suspense.
However history.pushState and history.replaceState are supported for CSR shallow routing.
I believe the same support should be introduced for the client-side search parameters tracking via useSearchParams hook as it is currently exclusively allowed to be used inside a <Suspense> wrapper. As Suspense opts into streaming. Unnecessary streaming is a performance bottleneck for the things you want to do exclusively on the client-side only, for example: e-commerce product lists, CSR filtering, manipulating UI client-side state which is completely unrelated to RSC's.
Proposal
Expose a shallow option for useSearchParams that would enable to subscribe to search params changes (router.push should be included) on the client-side without needing the use of a <Suspense> wrapper.
Expose additional router event that would indicate that a push was made (should be compatible with shallow routing otherwise)
If it is possible to listen to searchParams via native browser api somehow, docs improvements would solve this issue (with respect of next router)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Prerequisites
This thread was started because of answers coming from #70574. There's no clear answer if/how shallow searchParams are/can be supported without the
<Suspense>
wrapper.Goals
searchparams
changes and state retrieval.searchParams
.Non-Goals
No response
Background
In the app router it is currently not possible to listen for query parameters purely on the client-side without opting in to Suspense.
However
history.pushState
andhistory.replaceState
are supported for CSR shallow routing.I believe the same support should be introduced for the client-side search parameters tracking via
useSearchParams
hook as it is currently exclusively allowed to be used inside a<Suspense>
wrapper. AsSuspense
opts into streaming. Unnecessary streaming is a performance bottleneck for the things you want to do exclusively on theclient-side
only, for example: e-commerce product lists, CSR filtering, manipulating UI client-side state which is completely unrelated to RSC's.Proposal
shallow
option foruseSearchParams
that would enable to subscribe to search params changes (router.push
should be included) on theclient-side
without needing the use of a<Suspense>
wrapper.Beta Was this translation helpful? Give feedback.
All reactions