Next.js Discord

Discord Forum

How Can i Detect Shallow Route Changes In Next13 ?

Unanswered
LaPerm posted this in #help-forum
Open in Discord
LaPermOP
i want to change location params without reloading and any other stuffs
new nextjs router will send a get request when i call router.push()

so what i did was using this code :
const url = new URL(window.location.href);
url.searchParams.set("cat", category);
window.history.pushState({}, "", url);

question is how can i detect this url change in my nextjs app ? is there any hook or anything like react router useLocation that i can add to useEffect dependency to detect url changes?

0 Replies