Next.js Discord

Discord Forum

App useRouter router.replace doesn't accept url objects?

Answered
Singapura posted this in #help-forum
Open in Discord
SingapuraOP
Why don't the functions for the router accept url objects in the app router?
Answered by Giant panda
You can always write a custom util function that maps an object to a string or just do it manually using pathname and URLSearchParams
View full answer

10 Replies

SingapuraOP
error
Giant panda
Because the API changed and the new router functions take a string.
SingapuraOP
what a pointless change 🤣
SingapuraOP
yeah ik
is there a way to make it like that then
cause strings are so jarring to handle
Giant panda
You can always write a custom util function that maps an object to a string or just do it manually using pathname and URLSearchParams
Answer
SingapuraOP
alright thanks what an odd change ¯_(ツ)_/¯