jsonwebtoken-redis wraps the popular jsonwebtoken library to add Redis-backed token expiration, invalidation, and refresh capabilities. Token expiration is managed entirely by Redis keys, allowing you to invalidate tokens by removing the key, or postpone expiration via the touch command. Unlike the base jsonwebtoken library, all methods return Promises (no callbacks) and require a Redis client. Version 1.0.6 is the latest stable release, with no release cadence documented. Key differentiators: Redis-managed TTL, token destroy/touch, automatic jti generation via uuid.
npm install jsonwebtoken-redisNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates full lifecycle: sign, verify, touch (extend TTL), and destroy (invalidate) a JWT using Redis-backed expiration.
Use only expiresKeyIn option in sign() to allow Redis-managed TTL and enable touch().
Use CommonJS require() or dynamic import with default export.
Ensure Redis client is connected before using jwtRedis methods. Handle connection errors.
Monitor jsonwebtoken changelog and update jsonwebtoken-redis accordingly (it may lag behind).
const jwtRedis = new JwtRedis(client, options); jwtRedis.sign(payload, secret, options);
Instantiate with new JwtRedis(client, options) before calling instance methods.
await client.connect(); before using jwtRedis.
Ensure secret is a non-empty string. Use process.env.JWT_SECRET ?? 'fallback'.