How Laravel Sanctum Tokens Actually Work
When a user authenticates with Sanctum, Laravel generates a random token string and stores a hashed version in the personal_access_tokens table. On each request, the plain token is sent in the Authorization header, Laravel hashes it, and looks it up in the database to find the associated user.
This is the opposite of JWT. There is no payload, no signature verification, no expiry baked into the token itself — all of that lives in the database record.
How JWT Tokens Work
A JWT is a base64-encoded string with three parts: a header, a payload (user data/claims), and a cryptographic signature. The server validates the signature on every request — no database lookup needed. The token itself proves who the user is.
Sanctum vs JWT — Full Comparison
| Feature | Sanctum | JWT |
|---|---|---|
| Token type | Opaque (random string) | Self-contained (encoded payload) |
| Database lookup per request | Yes | No — stateless |
| Token revocation | Easy — delete DB row | Hard — needs denylist |
| Official Laravel package | Yes | No (tymon/jwt-auth) |
| SPA / cookie auth support | Yes — built in | No |
| Cross-service / microservices | Limited | Yes — ideal |
| Setup complexity | Simple | More config needed |
Which One Should You Use?
Use Sanctum when:
- Building a standard Laravel REST API or SPA
- You need token revocation to work reliably (logout, ban user, rotate tokens)
- You want official Laravel support and long-term stability
- Your app is a single service, not a distributed system
Use JWT when:
- Building microservices where multiple independent services need to validate the same token
- You need stateless auth with zero database reads on every request
- Integrating with non-Laravel systems that expect standard JWT
- You need to embed custom claims in the token itself
For the vast majority of Laravel projects — including every API I've built professionally — Sanctum is the right choice. It's simpler, safer by default, and token revocation just works. Reach for JWT only when you genuinely need stateless cross-service authentication, not just because it sounds more sophisticated.
Can You Use JWT with Sanctum?
Not natively — they are separate packages with different approaches. However, you can configure Sanctum to work alongside JWT if needed, or use a package like sanctum-jwt that adds JWT-style tokens to Sanctum. In practice, very few projects need this hybrid approach.