Changing search params without reloading page data?
Answered
Himalayan posted this in #help-forum
HimalayanOP
Hey is it possible to change the search params on the same site, i have a page where i would like something like ?selected=<id> on the url but i dont want it to refresh the data in the server component
Answered by joulev
[window.history.pushState](https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#windowhistorypushstate) or window.history.replaceState (same documentation page)
4 Replies
@Himalayan Hey is it possible to change the search params on the same site, i have a page where i would like something like ?selected=<id> on the url but i dont want it to refresh the data in the server component
[window.history.pushState](https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#windowhistorypushstate) or window.history.replaceState (same documentation page)
Answer
@Himalayan Hey is it possible to change the search params on the same site, i have a page where i would like something like ?selected=<id> on the url but i dont want it to refresh the data in the server component
that what joulev said. Also if you want to use the url as state management, you want to use nuqs: https://nuqs.47ng.com/
HimalayanOP
Interesting thanks
@Himalayan Interesting thanks
Sure thing. Please mark solution