Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

laurentm's avatar

Laravel + VUE SPA

Assuming I am building an app in a spa mode with Vue and Laravel via API rest or grpahql I have the following roles:

  • Super admin
  • Admin
  • Client
  • Company staff

I got a left menu where items in this menu should be visibles based on roles (and obviously related routes accessible depending on those same roles by following those visibility).

What is the best way to implement this? Vue Auth (e.g websanova) + Laravel Auth (Passport ? Sanctum) ? Vue Auth only ? Laravel Auth only ?

I am a bit confused about what is the most secure way to perform this functionality.

0 likes
4 replies
fylzero's avatar

@laurentm Personally I would use Sanctum for your auth layer. It is simple/clean and accounts for authorizing Vue securely as well as a rest API. I admittedly haven't worked with GraphQL much yet, so I would probably stick with Rest. As far as managing user roles/permissions I'd strongly recommend checking out the Spatie package https://spatie.be/docs/laravel-permission/v3/introduction

As far as passing rights back to the interface, I typically would pass values into meta headers, then to state management in Vue, like VueX.

All of this probably sounds more complicated than it really is. The Spatie package is a breeze to learn, just hunt down some youtube vids, you'll see it is pretty simple. Require, run migrations, you'll have access to cool things. All well documented.

If you're not familiar with VueX, I suggest checking out The Net Ninja intro to VueX course. Helped me understand and get a "hello world" up fairly quickly.

24 likes
laurentm's avatar

Thank you for replying, this is the information i was missing: "As far as passing rights back to the interface, I typically would pass values into meta headers, then to state management in Vue, like VueX."

1 like
fylzero's avatar

Glad to help, please mark best answer if that solved your issue. Thanks!

24 likes
laurentm's avatar

can you give an example of code to do this?

Please or to participate in this conversation.