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

Corvin's avatar

Laravel Sanctum SPA-How to add Vue Router Guard

Hi everyone, how can I add an authentication guard to my vue router using Laravel Sanctum SPA? I know that for API token, simply returning the token and assigning the token to vuex state will enable access to guarded routes (like JWT), but how I do this on SPA Authentication?

0 likes
4 replies
Corvin's avatar

Hi, I watched that too, it didn't show how to bypass or guard a protected route. My route still check the token in local storage to allow access to dashboard. But that is not how SPA handles authentication since its not token based(as my route guard was previously a JWT auth). Knowing that the backend knows the authenticated user, how will the front end knows that the user is authenticated too?

Corvin's avatar

Got it! Found it in one of Andre's youtube videos. Thanks

Please or to participate in this conversation.