DEV Community

Manisha Batesar
Manisha Batesar

Posted on

What is JWT?

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)