laravel/sanctum
Laravel Sanctum is a lightweight authentication package for Laravel, ideal for SPAs and simple APIs. It supports cookie-based session auth for first-party SPAs and API tokens for personal access tokens, with minimal configuration and Laravel-first integration.
last_used_at or CSRF protection).expires_at).Adopt Sanctum if:
Look elsewhere if:
For Executives: "Sanctum is a lightweight, Laravel-native solution to replace our custom JWT or session-based auth for SPAs/APIs. It cuts development time by 60% (no need to build token validation, CSRF protection, or session management from scratch) while adding security features like token expiration and pruning. Used by [X] projects, it’s maintained by Laravel’s core team, ensuring long-term stability. This aligns with our roadmap to modernize our backend for [Y] use cases, reducing tech debt and enabling faster feature delivery."
For Engineering: *"Sanctum gives us a drop-in auth system for SPAs/APIs with:
composer require laravel/sanctum)."*For Developers: *"Sanctum replaces our hacky auth system with:
HasApiTokens trait for easy token management in models.last_used_at tracking).
Example:// Generate a token for a user
$token = $user->createToken('api-token')->plainTextToken;
// Use in SPA
fetch('/api/data', {
headers: { 'Authorization': `Bearer ${token}` }
});
Pros: No Passport bloat, works out-of-the-box. Cons: Limited to Laravel/PHP."*
How can I help you explore Laravel packages today?