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 true
replace
: If true
, replaces the current history entrynoScroll
: If true
, prevents scrolling to top when navigatingExample:
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 setSearchParams
setSearchParams
: 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 propertyreplace
: Optional flag to replace the current history entryExample:
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 noScroll
defaultPrevented
: 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: