Registry / storage / connect-redis-crypto

connect-redis-crypto

JSON →
library4.0.5jsnpmunverified

Redis session store for Express/Connect with optional encryption support. Current stable version is 4.0.5 (Node >= 8.0.0). Provides session storage using Redis, with features like TTL management, configurable serializers, and SCAN-based iteration. Unlike standard connect-redis, it includes a `secret` option in the store to encrypt session data at rest in Redis. The API is compatible with express-session and supports multiple Redis client libraries including redis, ioredis, and redis-mock. Updated irregularly; v4 introduced breaking changes from earlier versions.

npm install connect-redis-crypto
INSTALL
IMPORT
SIG · CONNECT-REDIS-CRYP
C
connect-redis-crypto
storagejavascriptv4.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const RedisStore = require('connect-redis-crypto')(session)
const { RedisStore } = require('connect-redis-crypto')
The module exports a function that must be called with the session object; does not export a class directly. CJS only.
RedisStore
const RedisStore = require('connect-redis-crypto')(session); const store = new RedisStore({ client, secret: 'mysecret' })
const store = new RedisStore({ client })
The `secret` option is required for encryption; omitting it will store data in plaintext.
default (ESM)
import connectRedisCrypto from 'connect-redis-crypto'; const RedisStore = connectRedisCrypto(session)
import { default as connectRedisCrypto } from 'connect-redis-crypto'
ESM usage is possible but not documented; the package is primarily CJS. Use dynamic import or require.

Shows how to set up an Express session store with Redis and optional encryption using connect-redis-crypto.

const redis = require('redis'); const session = require('express-session'); const connectRedisCrypto = require('connect-redis-crypto'); const RedisStore = connectRedisCrypto(session); const client = redis.createClient({ host: process.env.REDIS_HOST || 'localhost', port: process.env.REDIS_PORT || 6379, password: process.env.REDIS_PASSWORD || '' }); const app = require('express')(); app.use(session({ store: new RedisStore({ client, secret: process.env.SESSION_SECRET || 'squirrel' }), secret: 'keyboard cat', resave: false, saveUninitialized: false })); app.get('/', (req, res) => { req.session.views = (req.session.views || 0) + 1; res.send(`Views: ${req.session.views}`); }); app.listen(3000, () => console.log('Server running on port 3000'));
Debug
Known issues
breakingv4 changed the export from a class to a function that must be called with session object
fix
Replace `const RedisStore = require('connect-redis-crypto');` with `const RedisStore = require('connect-redis-crypto')(session);`
affects: >=4.0.0
gotchaSecret option is required in the store options to enable encryption; omitting it stores data in plaintext
fix
Always pass `secret` option to `RedisStore({ client, secret: 'your-secret' })`
affects: >=1.0.0
gotchaTTL reset behavior: `express-session` does not update `expires` until end of request; manual `session.save()` will have stale TTL
fix
Do not rely on `session.expires` before request completion; consider using `disableTouch` if auto-TTL reset is undesirable
affects: >=1.0.0
deprecatedThe `redis` npm package v3+ has breaking changes; this store may not be compatible with newer versions
fix
Use `redis` v2.x or `ioredis`; check the store's peer dependency range
affects: >=4.0.0
Errors
Common errors & fixes
TypeError: RedisStore is not a constructor
Using v4+ without calling the exported function with `session` object
fix
Use `const RedisStore = require('connect-redis-crypto')(session);`
Error: secret option is required for encryption
Missing `secret` in store options
fix
Pass `secret` to `new RedisStore({ client, secret: 'mysecret' })`
Redis connection refused
Redis server not running or wrong host/port
fix
Ensure Redis is running and `client` is configured with correct host and port
Upgrade
Version history
4.0.5latest on npm
Audit
Dependencies
redisrequiredRequired Redis client for store operations
express-sessionrequiredMiddleware that uses the store; required for session management
Agent activity
27 hits · last 30 days
node
26
Resources
connect-redis-crypto — npm install connect-redis-crypto · libregistry