JWT (JSON Web Token)is a token (like a small digital key) that the backend creates after a user logs in.
π It tells the server: βYes, this user is already logged in.β
We can think of JWT like an ID card or an entry pass.
Why use JWT?
Without JWT: youβd have to send your password every time β unsafe and slow.
With JWT: login once, get a token, and send it with every request. The server checks it and allows access.
JWT is made of three parts:
Header: token type & algorithm
Payload: user info (never store passwords)
Signature: secret key that proves the token is real
How it works:
π User logs in β server creates JWT
π Token sent to frontend β stored (usually in localStorage)
π User makes requests β token sent in headers
π Server checks token β allows or denies access
Thanks for reading!β€οΈ

Top comments (0)