Support the ongoing development of Laravel.io →
Session Authentication Laravel

Hello everyone! I have very exciting question form me.

What is a right way to authenticate your SPA JavaScript application (VueJS+Router, ReactJS+Router etc.)? I have investigated this question and found very different results for such standard feature as authentication. In most cases developers uses laravel/passport (Full OAuth2 server implementation) to just authenticate frontend application, which is looks strange for me.

Someone uses Personal Access Token:

Someone uses Password Grant:

Anotherone uses tymon/jwt-auth package:

Someone else uses CreateFreshApiToken middleware to attach api token to cookie, how recommended in the documentation:

And also have found answers like:

Just use sessions!

So, the main questions:

  1. Whats the profit to use Password Grant or Personal Access Tokens for your JavaScript app, if much simpler and recommended way it’s to use - CreateFreshApiToken middleware?

  2. Is this not overhead, to install Full OAuth2 Implementation, to just authenticate Frontend SPA with CreateFreshApiToken middleware which just attach token to cookie?

  3. Is it make sense to use laravel/passport with CreateFreshApiToken middleware if it’s just attach token to cookie like in case with sessions?

  4. Is there a reason to use simple JWT with tymon/jwt-auth, if yes, so which?

And main question, so, What is a right way to authenticate your JavaScript SPA Frontend Application?

P.S. I don’t ask about mobile applications, or 3rd parties, just your Frontend JavaScript application.

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.