MongoDB session store for Express and Connect written in TypeScript. Current stable version is 6.0.0, released with breaking changes from v4 rewritten in TypeScript. Supports Express 4.x/5.0, Connect 3.x, and MongoDB Node driver 5.x-7.x, with CI testing across Node 20, 22, and 24. Key differentiator is seamless integration with express-session providing MongoDB-backed session persistence, lazy session updates, transparent encryption, and configurable auto-removal of expired sessions. Requires express-session and mongodb as peer dependencies.
npm install connect-mongoNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic Express session setup using MongoStore.create() with MongoDB connection string, TTL, native auto-removal, and lazy session update.
Upgrade Node to >=20.8.0, mongodb driver to >=5.0.0
Replace `new MongoStore(options)` with `MongoStore.create(options)`
Use `autoRemove: 'interval'` and `autoRemoveInterval: value` or `autoRemove: 'native'`
Ensure MongoStore.create() is called inside a valid Express/Connect app with session middleware
Use direct import of MongoStore instead of destructured { MongoStore }Ensure mongoUrl includes correct username, password, and authSource (e.g., ?authSource=admin)
Use `const MongoStore = require('connect-mongo').default` or switch to ESM importWait for the mongoose connection? Or use mongoUrl option to let connect-mongo manage the connection