Docs
useRouter
useRouter
useRouter is a hook that can be used to manipulate with router
Tip: Use created <Link /> component for navigation unless you have a specific requirement for using useRouter.
useRouter
return's following object
router.pathname
: Current URL's pathnamerouter.push(pathname: string)
: Pushes new state to browser history APIrouter.replace(pathname: string)
: Replaces browser history state with new onerouter.refresh()
: Refresh the current route.router.back()
: Navigate back to the previous route in the browser’s history stack.router.forward()
: Navigate forward to the next route in the browser’s history stack.