laravel/sanctum
Laravel Sanctum is a lightweight authentication package for Laravel, designed for SPAs and simple APIs. It supports secure session-based auth for first-party SPAs and personal access tokens for API clients with minimal setup.
HasApiTokens trait) simplify compliance and security.laravel/sanctum) and a single migration (php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"). No complex configuration required for basic use.auth:sanctum) for seamless route protection, compatible with existing Laravel apps.personal_access_tokens table) or caching layers (e.g., Redis) to avoid performance bottlenecks.Laravel Version Compatibility:
Performance Requirements:
tokenable_id, created_at) and caching strategies planned?Security Needs:
stateful domains must align with frontend origins.Migration Path:
oauth_access_tokens) that need migration or coexistence?Team Expertise:
HasApiTokens trait for token management.auth:sanctum for route protection, EnsureFrontendRequestsAreStateful for CSRF.routes option in config/sanctum.php).actingAsAs($user)).Authorization: Bearer <token>) work with React, Vue, or Angular./api/auth/login responses) to ensure compatibility with Sanctum’s token format.composer require laravel/sanctum.php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider".php artisan migrate.Authorization: Bearer headers.sanctum, web) via config/auth.php.throttle middleware.PersonalAccessTokenCreated, PersonalAccessTokenDeleted events.axios with Authorization headers.stateful domains to include Next.js’s default host (localhost or custom domains).config/sanctum.php (e.g., stateful domains, token TTL).HasApiTokens on user models or custom token models.expires_at column).PersonalAccessTokenCreated) for auditing.personal_access_tokens table).php artisan sanctum:analyze (for token issues), Laravel’s dd() for middleware inspection.laravel-sanctum) for community support.How can I help you explore Laravel packages today?