Skip to content

Adding global route helper using groups in Vue Inertia app #652

Answered by bakerkretzmar
CamKem asked this question in Q&A
Discussion options

You must be logged in to vote

Injecting route in every component is the only way to make it available if you're using the composition API. You can also keep @routes in your root template and then it'll be available globally, but your IDE might complain about that.

If you need the available routes to change on every navigation event then you'll have to either set up your own route function, as you've done, or listen for Inertia's navigation events and manually update the global Ziggy config. Try this too: #567

The simplest option here is probably for you not to use the Vue plugin and to just do what the Vue plugin is doing yourself (so use the route function wrapper you've got above and provide it globally yourself). Y…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bakerkretzmar
Comment options

Answer selected by CamKem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants