Next.js Discord

Discord Forum

alternative to router.back for closing a modal

Unanswered
Czechoslovakian Wolfdog posted this in #help-forum
Open in Discord
Czechoslovakian WolfdogOP
I'm building a sort of stories modal using next.js app router parallel and intercepting routes.
On next.js docs we are told to use router.back() for going back and closing the modal page. But from this modal I'm intended to make it possible to go to other stories and this would change the url, so, wouldn't router.back just go pack to previous stories modal?

I tried using router.push but it didn't work. Is there any other way to close the intercepting route than to use backwards navigation til it gets back to "/"?

0 Replies