Skip to main content

Auth for Node.jss

Auth in Node.js covers identifying users and limiting what they can do. Passwords are stored as bcrypt or argon2 hashes, and logins create a server session in a cookie or a signed JWT. Authorisation then checks roles or ownership in middleware before a handler touches data.

Stage: Security and Auth · Part of the Node.js roadmap · Last reviewed 19 November 2026

What to learn in Auth

Auth interview questions

Why hash passwords with bcrypt instead of SHA-256?

General hashes are fast, so attackers can test billions of guesses per second. bcrypt and argon2 are deliberately slow, add a unique salt and have a tunable cost, which makes stolen password databases much harder to crack.

What are the trade-offs between sessions and JWTs?

Sessions keep state on the server, so they are easy to revoke but need a shared store when scaling. JWTs carry state in the token, which avoids lookups but makes immediate revocation harder, so keep their lifetime short.

Where Auth fits in the Node.js roadmap

Auth belongs to the Security and Auth stage (intermediate level), which takes about 22 hours. Protect the API.

Back to the full Node.js roadmap