useRouter
Overview
The useRouter
hook provides access to various data about the current route, as well as methods to navigate between pages, as seen in the below example:
useRouter
result
pathname
:string
- Returns the current path namequery
:Record<string, string>
- This object contains all the query params of the current route
The following methods are included inside router
:
router.push
Handles client side page navigation quickly. Useful for internal links, or for when you need to change url in some JS.
router.replace
Handles client side page navigation in the same way as router.push
, but it will replace the current entry in the browser history stack.
Router methods parameters
Edit page