MongoDB session store for Connect and Express (v0.1.4). Supports replica sets with detailed configuration, SSL connections, and optional Mongoose integration. It works with Express 3.x and 4.x (with express-session). The package has a slow release cadence (last update), and requires manual invocation as a factory function. Compared to connect-mongo, it offers replica set support out of the box but is less maintained.
npm install connect-mongostoreNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Express 4.x session store setup with connect-mongostore, using environment variables for configuration.
Use the pattern: const MongoStore = require('connect-mongostore')(session); where session is the session middleware instance (express-session or express.session).Provide the database name as a string, or an object with 'name' and 'servers' properties for replica sets. Do not use a MongoDB connection URI.
Consider migrating to a maintained alternative like connect-mongo or connect-mongodb-session.
Set 'stringify: true' in options to ensure JSON serialization, or ensure session objects are plain objects.
Use const MongoStore = require('connect-mongostore')(session); where session is express-session (or express for 3.x).Pass the database name as a string to 'db', e.g., { db: 'myapp-sessions' }. Do not use a full URI like 'mongodb://localhost:27017/db'.Ensure MongoDB is running and accessible. Use environment variables to set host and port, e.g., { host: process.env.MONGO_HOST || 'localhost', port: process.env.MONGO_PORT || 27017 }.