If you're going to use it for both session based and token based authentication then Sanctum is a very good choice.
which package should i use to build my API?
Hello guys,
I am working on laravel 8 project and i should provide all functions and build API for mobile application.
I need Authentication system to work on mobile application also.
So which API Package should i use: Passport OR Sanctum.
in the docs they mention in Sanctum intro:
Laravel Sanctum provides a featherweight authentication system for SPAs (single page applications), mobile applications, and simple, token based APIs
so it's better to use Sanctum for Mobiles Application? please advice me before starting
It really depends on what features you are going to build.
I personally don't see the need of passport unless 'OAuth2' is a requirement.
And it's recommended if this is your first time building a token-based API to use sanctum rather than passport.
Reference:
However, if you are attempting to authenticate a single-page application, mobile application, or issue API tokens, you should use Laravel Sanctum. Laravel Sanctum does not support OAuth2; however, it provides a much simpler API authentication development experience.
Please or to participate in this conversation.