Updating Aysnc Search Params
Answered
Baird's Sandpiper posted this in #help-forum
Baird's SandpiperOP
With the new async search params pattern, I am updating search params with NUQS (client component) and the url changes but do i have to force a refresh / reroute every time I update a search param to refetch on the page.ts ? As of now the value from the awaited search parameter does not change
Answered by B33fb0n3
when you need to update the page but also want to directly change the state, I would use nuqs and use nuqs's option to reload the page. The syntax for it is:
const [state, setState] = useQueryState('foo', { shallow: false })
6 Replies
@Baird's Sandpiper With the new async search params pattern, I am updating search params with NUQS (client component) and the url changes but do i have to force a refresh / reroute every time I update a search param to refetch on the page.ts ? As of now the value from the awaited search parameter does not change
yes, you need to refresh the page. Nuqs only changes the clientside url. However you can force nuqs to refresh it for you if needed
Baird's SandpiperOP
@B33fb0n3 thanks for the response. whats the best option in your opinion? use NUQS or just router.push(currentPathname) after update?
@Baird's Sandpiper <@301376057326567425> thanks for the response. whats the best option in your opinion? use NUQS or just router.push(currentPathname) after update?
when you need to update the page but also want to directly change the state, I would use nuqs and use nuqs's option to reload the page. The syntax for it is:
const [state, setState] = useQueryState('foo', { shallow: false })
Answer
Asian black bear
useQuery(somethingParser, {
shallow: false, // This forces RSCs to reload
})
@Baird's Sandpiper solved?