Registry / storage / connect-redis

connect-redis

JSON →
library9.0.0jsnpmunverified

Redis session store for Connect/Express, v9.0.0. Provides persistent session storage using Redis backend. Requires express-session and redis v5+. Active maintenance, releases follow express-session updates. Key differentiator: widely used, supports Express 4.x/5.x, custom TTL, serializers, and Redis SCAN for list operations. Ships TypeScript types.

npm install connect-redis
INSTALL
IMPORT
SIG · CONNECT-REDIS
C
connect-redis
storagejavascriptv9.0.0
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.

RedisStore
import { RedisStore } from 'connect-redis'
const RedisStore = require('connect-redis')
ESM only since v9. Named export. Types included.
default import
import { RedisStore } from 'connect-redis'
import RedisStore from 'connect-redis'
No default export. Use named import instead.
require
const { RedisStore } = require('connect-redis')
const RedisStore = require('connect-redis').default
CommonJS destructuring works in older Node, but ESM is recommended.

Sets up Express session with RedisStore, using named import, async client connection, and required session config options.

import { RedisStore } from 'connect-redis'; import session from 'express-session'; import { createClient } from 'redis'; import express from 'express'; const app = express(); const redisClient = createClient({ url: process.env.REDIS_URL ?? 'redis://localhost:6379' }); await redisClient.connect(); const redisStore = new RedisStore({ client: redisClient, prefix: 'myapp:', }); app.use(session({ store: redisStore, secret: process.env.SESSION_SECRET ?? 'keyboard cat', resave: false, saveUninitialized: false, })); app.get('/', (req, res) => { res.send('Session store with Redis'); }); app.listen(3000);
Debug
Known issues
breakingconnect-redis v8+ dropped support for callbacks and legacy Redis. Use Node Redis v4+.
fix
Migrate to redis v4+ or v5, use async client.connect() and promise-based API.
affects: >=8.0.0
breakingconnect-redis v9 is ESM-only. CommonJS require may fail in Node <22 or without package.json type:module.
fix
Convert project to ESM or use dynamic import().
affects: >=9.0.0
deprecatedUsing default import (import RedisStore from 'connect-redis') will cause runtime error.
fix
Use named import: import { RedisStore } from 'connect-redis'.
affects: >=9.0.0
gotchaRedis client must be connected before passing to RedisStore. Missing await client.connect() leads to silent session failures.
fix
Call await redisClient.connect() after createClient and before new RedisStore.
affects: >=8.0.0
gotchaprefix is appended to any prefix set on the redis client itself, leading to double prefixing.
fix
Set prefix either on client or on RedisStore, not both.
affects: >=0.0.0
gotchaTTL does not update if session.expires is not set; defaults to 86400 seconds. express-session does not update expires until end of request.
fix
Manually set session.cookie.expires or use dynamic TTL callback.
affects: >=0.0.0
deprecatednode_redis (redis v3) is no longer supported. Only redis v4+.
fix
Replace redis package with 'redis' v4+ and update API calls.
affects: >=8.0.0
Errors
Common errors & fixes
TypeError: RedisStore is not a constructor
Using default import or incorrect import style
fix
Import { RedisStore } from 'connect-redis'
Error: The client is closed. Use client.connect() before creating a RedisStore.
Redis client not connected before use in store
fix
Await client.connect() before instantiating RedisStore
TypeError: Cannot read properties of undefined (reading 'on')
Passing null or undefined as client option
fix
Ensure a valid redis client is provided: client: createClient()
Warning: connect-redis requires express-session middleware
session middleware not used before store
fix
Add app.use(session({... store: redisStore ...}))
Upgrade
Version history
9.0.0latest on npm
Audit
Dependencies
redisrequiredPeer dependency: Redis client >=5
express-sessionrequiredPeer dependency: required to use session middleware
Agent activity
27 hits · last 30 days
node
24
Resources
connect-redis — npm install connect-redis · libregistry