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

KNietzsche's avatar

SPA / vue-router / authorizations

I'm not currently understanding how the authorizations are managed with a SPA / vue-router... I cannot see the link between a template and policies for example....

how do we translate basic laravel stuff as @if (Auth::check()) or @can('hasXXX', Auth::user()) using Vue templates ?

Do we need to make ajax requests for each new Vue component we create to check for an authorization ? How developers manage that topic with complete Vue applications ?

Each time we select a new route with vue-router as well ?

Now, for the moment, after some tests and with my questions above... I don't see the interest of using Vuetify for example as a template for an application... Do you have some links for videos or documentations about that topic... I'm interested to know and haven't find answers until now.... Thks

0 likes
6 replies
KNietzsche's avatar

Cannot believe people develop with Vuejs without an answer to this question !! How can you use that if you want to hide a button or display some data depending on a role or permission ? How to hide a component if the user has no authorization ? If we need to create api and call them each time and adjust the templates with tons of code to achieve such a basic thing....damm I cannot believe it. At this point, for me, VueJs can only be used for general components...not for a complete application...or it will be a nighmare to code and maintain... Cannot find something about that...cannot believe people didn't think about that... Please share your opinion...did I missed something ?

KNietzsche's avatar

well @topvillas everywhere it is written Vuejs is a javascript framework...even in Jeff's video lessons....so, if authorizations are not managed, for me I cannot imagine to write a complete SPA application...it's a real basic application or a non sense.... But I found 2 Vue components

vue-acl and vue-kindergarten

They seem to be interesting, but I didn't test them for now... I have read some things about using Vuex (stores) as well, but I will continue to think and invesigate on this

Here is an article about that Role Based Authorization for your Vue.js and Nuxt.js Applications Using vue-kindergarten

tykus's avatar

Data-driven apps means you only send to the view layer what the user can interact with. Any requests to the Laravel app are filtered through your gate.

1 like
KNietzsche's avatar

@tykus if you use Vuetify and Vue-router...how do you easily do that ? through ajax checks ? Laravel is not a big help in such a SPA application, except for the backend API...you need to almost reinvent the wheel for each component, each role, each authorization...no ? Maybe using Nuxt ? but there is not a lot of things about that now...

benmack180's avatar

I'm also interested in this question but can't find any detail answer yet, have you found any solution?

Please or to participate in this conversation.