Next.js Discord

Discord Forum

Shallow routing not working with `useRouter.push` from `next/navigation`

Unanswered
jaggi73 posted this in #help-forum
Open in Discord
I am using push method of the useRouter hook imported from next/navigation with config passed as {shallow: true} and only changing the query params. However, it is still making server calls (the API call on the page.tsx is running again) on change of the query params. How can I change the query params without making any server calls

4 Replies

Something equivalent to push(route, undefined, {shallow: true}) from the pages directory
Any help please?
Still havent been able to figure this out
Using
window.history.pushState(
                {},
                "",
                window.location.pathname + queryString
            );
for now
Sun bear
There is no {shallow: boolean} property for the newer version of useRouter from next/navigation.
The only property push function can take as a second parameter is {scroll: boolean}.

See more: https://nextjs.org/docs/app/api-reference/functions/use-router#userouter