Well no responses yet but I'm still searching for an answer for a recommended, perhaps "built in", way to handle this. I'm sure I'm going to need to access route information a few more times throughout the app and it'll be nice to know I an easily. I just have to believe somebody has ran into this before and has a much cleaner solution. Anyways, I've figured out a couple ways to at least get the job done for now and figured I'd add them here to see if it gets the ball rolling.
Solution 1
Parse out the parts I need directly from the url within the Vue component (not liking this solution):
let url = new URL(document.location);
let token = url.pathname.split(/[\/]/).pop();
let email = url.searchParams.get('email');
Solution 2
The Inertia.js Laravel package just came out with some new middleware that can be used to share backend data with the frontend:
public function share(Request $request)
{
return array_merge(parent::share($request), [
'route' => function () use ($request) {
return [
'params' => $request->route()->parameters(),
'query' => $request->all(),
];
},
]);
}
And then access them in the Vue component like so (better solution?):
let token = this.$page.props.route.params.token;
let email = this.$page.props.route.query.email;
Do either of the above solutions help display what I'm trying to do here? Any cleaner solutions out there?
Thanks all!