🔐 JWT Tokens with Cookies and Redis/in-Memory in One Line — The Magic of auth-verify
Jahongir Sobirov

Jahongir Sobirov @jahongir2007

About: Full stack developer and IUT student

Location:
Navoi, Uzbekistan
Joined:
Mar 8, 2021

🔐 JWT Tokens with Cookies and Redis/in-Memory in One Line — The Magic of auth-verify

Publish Date: Oct 27
2 0

Handling authentication in Node.js often means juggling JWTs, cookies, and Redis manually — configuring middleware, managing sessions, and writing repetitive code.

auth-verify simplifies all that.
It provides a clean and modern way to manage JWT authentication, secure cookies, OTPs, and more — all with minimal setup.

const Auth = require("auth-verify");
const auth = new Auth({ jwtSecret: "MySecret" storeTokens: "redis" }); // or you can use 'memory' for saving your tokens in-memory

// Sign a JWT and set it automatically as an httpOnly cookie
await auth.jwt.sign({ userId: 1 }, "1h", { res });

// Verify the token (reads cookie automatically)
await auth.jwt.verify({ req });
Enter fullscreen mode Exit fullscreen mode

✅ What happens under the hood:

  • Token is generated and securely stored in Redis
  • A safe, httpOnly cookie is automatically set on the response
  • No need to manually use res.cookie() or middleware
  • Works seamlessly with Express, Fastify, or any custom server setup

🧰 Why Developers Love It

  • Simple JWT management — sign, verify, revoke in one line
  • Secure cookies — no cookie-parser needed
  • Built-in Redis / memory token store
  • Includes OTP system and sender support (e.g., Telegram, email, SMS)
  • Works anywhere — Express, custom HTTP servers, even bots

💡 Example: Minimal Login System

app.post("/login", async (req, res) => {
  const token = await auth.jwt.sign({ userId: 1 }, "1h", { res });
  res.json({ success: true, token });
});

app.get("/me", async (req, res) => {
  const user = await auth.jwt.verify({ req });
  res.json({ user });
});
Enter fullscreen mode Exit fullscreen mode

That’s it.
No extra middleware. No manual cookie handling.
Just secure authentication with a clean API.

📦 Install

npm install auth-verify
Enter fullscreen mode Exit fullscreen mode

v🌐 Learn More

✨ Summary

auth-verify gives you:

  • JWT + Cookies + Redis in one simple API
  • Secure authentication without boilerplate
  • Full control when you need it

If you want a modern, simple, and flexible authentication solution — give auth-verify a try.

Comments 0 total

    Add comment