useRouter
React hook that provides access to router state and navigation methods in Buntal applications.
Source
Type Definition
function useRouter(): {
pathname: string
search: string
href: string
protocol: string
hostname: string
hash: string
push: (url: string) => void
replace: (url: string) => void
back: () => void
reload: () => void
}
Properties
Property | Type | Required | Default | Description |
---|---|---|---|---|
pathname | string | ✅ | - | Current pathname of the URL |
search | string | ✅ | - | Query string portion of the URL |
href | string | ✅ | - | Complete URL including protocol, host, and path |
protocol | string | ✅ | - | Protocol portion of the URL (http:, https:, etc.) |
hostname | string | ✅ | - | Hostname portion of the URL |
hash | string | ✅ | - | Hash fragment portion of the URL |
Methods
push
Navigate to a new URL and add it to the browser history
Parameters
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
url | string | ✅ | - | URL to navigate to |
Returns
void
replace
Navigate to a new URL and replace the current entry in browser history
Parameters
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
url | string | ✅ | - | URL to navigate to |
Returns
void
back
Navigate back to the previous page in browser history
Returns
void
reload
Reload the current page
Returns
void
Last modified: 2025-06-10