Next.js Discord

Discord Forum

router.push's `as` not properly working in next 12.3.2

Unanswered
Northern Saw-whet Owl posted this in #help-forum
Open in Discord
Northern Saw-whet OwlOP
I'm trying to navigate users to /?modal=true while having the url in browser be shown as /page for example. I'm trying to use the as prop to do so however, im getting redirected to the page instead of having the query param of modal added. How do i fix such thing?

router.push('/?modal=true', '/page')


* I'm using next 12.3.2 still, no chance of upgrading now. so please if you have a solution make it related to this version of next.

1 Reply

Northern Saw-whet OwlOP
Such solution works however the url jumps from the href value to the as value. I want to achieve something similar to Vercel's Image Gallary Starter project example where the url is smooth.

https://nextjsconf-pics.vercel.app/

router.push(href).then(() => {
  window.history.replaceState({}, '', as)
})


* Again im limited by the old version of next so i can't use their Link component :(