Shallow redirect with App router
Unanswered
XandoR posted this in #help-forum
XandoROP
Hello there, question might sound stupid but... What's the equivalent of passing { shallow: true } to router.push options when using app router ?
4 Replies
Dwarf Crocodile
You can just use the native history api as stated in the app router documentation. https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#using-the-native-history-api
const params = new URLSearchParams(searchParams.toString())
params.set('sort', sortOrder)
window.history.pushState(null, '', `?${params.toString()}`)@Dwarf Crocodile ts
const params = new URLSearchParams(searchParams.toString())
params.set('sort', sortOrder)
window.history.pushState(null, '', `?${params.toString()}`)
XandoROP
And so this is the equivalent for shallow navigation ?
@XandoR And so this is the equivalent for shallow navigation ?
Dwarf Crocodile
Yes I think so