JWT (JSON Web Token) is a compact, self-contained token format used for authentication and authorization. It's a signed piece of data (usually JSON) that proves a user is authenticated without needing to check a database on every request. JWTs contain claims (user ID, roles, expiration) and are cryptographically signed so you can trust them. Common in API authentication.
Use JWTs for stateless authentication in APIs, microservices, or SPAs where you don't want to hit a database on every request. Perfect for mobile apps, serverless functions, or distributed systems. JWTs work well with OAuth—the OAuth flow returns a JWT access token. Don't use JWTs for session management in traditional web apps (use httpOnly cookies instead).
Cybersecurity
JSON Web Tokens—stateless authentication