Hook that returns a function to programmatically navigate between routes.
Type:
Parameters:
href: The destination path, can include query stringsoptions: Optional configuration
relative: If false, navigates to the absolute path without relative base. Defaults to truereplace: If true, replaces the current history entrynoScroll: If true, prevents scrolling to top when navigatingstate: Optional state object to pass to history.state, defaults to nullExample:
Hook that provides access to search parameters and a function to update them.
Type:
Returns: An array containing
searchParams: A reactive object with current search parameters that auto-updates when location.search changes or when modified via setSearchParamssetSearchParams: A function to update search parameters
params: Search parameters to merge with existing ones. Setting a property value to undefined, null or an empty string removes that propertyoptions: Optional configuration object
replace: Optional flag to replace the current history entry instead of pushing a new onestate: Optional state object to pass to history.state, defaults to nullExample:
Hook that registers a listener to be called before leaving the current route. This allows you to intercept navigation attempts and potentially prevent them, for example, to warn users about unsaved changes.
Type:
Parameters:
listener: A function that will be called with a RouteGuardEvent object when navigation away from the current route is attempted
event: The route guard event object containing:
to: The destination path being navigated tofrom: The current path being navigated fromoptions: Navigation options including relative, replace, and noScrolldefaultPrevented: Boolean indicating if the navigation has been preventedpreventDefault: Function to call to prevent the navigationretry: Function to retry the navigation later, with an optional force parameter to bypass guardsExample:
Hook that returns a reactive Location object containing information about the current URL. This object automatically updates when the URL changes.
Type:
Returns: A reactive Location object with pathname and other properties
pathname: The path portion of the URL excluding the query stringsearch: The query string portion of the URLhash: The hash portion of the URL including the # symbolstate: The state object associated with the current history entry passed via useNavigate or <Link> componentquery: A reactive object containing all query parameters of the URLExample: