Passing globally needed data in HandleInertiaRequests middleware

Just curious about this one.

When you want to pass data that you want to be globally available in your Inertia Vue app, is it a good practice to pass it in HandleInertiaRequests middleware?

If we do that, are we implementing something like a View Composer?

whoami (Daryl) Member
whoami (Daryl)
0
2
504
alex Member
alex
Moderator
Solution

Yeah it’s similar to a view composer, but you can control what gets loaded in with the ‘only’ array when making Inertia requests.

Let me know if you need any more advice for your specific use case!

whoami (Daryl) Member
whoami (Daryl)

Thanks, Alex. I learned about only from your Learn Inertia series 🎉