useRoute
hook
#2564
SantosVilanculos
started this conversation in
Ideas
`useRoute` hook
#2564
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Every JS/TS router provides a
useRoute
hook or an equivalent. Withlaravel/wayfinder
, we now have typed forms and links. However, a first-party Inertia.js router implementation is needed to access route parameters, name, path, etc., and to compare the current route name against a given route.API
The
useRoute
hook provides access to the following properties and methods:params
: An object containing the route parameters.path
: The encoded pathname section of the URL.fullPath
: The encoded URL associated with the current route, including path, query, and hash.query
: An object containing query parameters.hash
: The decoded hash section of the URL, starting with a#
.name
: The unique name for the route record.named
: A method to determine if the current request was routed to a given named route.Working Example
React Frontend
Laravel Backend
References
Beta Was this translation helpful? Give feedback.
All reactions