MongoDB Node.js Driver Documentation
The official guide to using MongoDB from JavaScript and TypeScript with the `mongodb` npm package: connecting, CRUD, aggregation, indexes, transactions, change streams and TypeScript types. Read it before reaching for an ODM, because Mongoose and most Node.js tools sit on top of this driver.
10.2k (node-mongodb-native)
GitHub · Sept 2026
7.6.0 (August 2026)
GitHub · Sept 2026
16.7M (week to 26 Sept 2026)
npm · Sept 2026
20.19.0 or later
npm · Sept 2026
Guide
Web Development
MongoDB
A weekend for the core, then reference
Intermediate
Free
What these docs cover
This is MongoDB's documentation for the official Node.js driver, the mongodb package on npm. In September 2026 the docs cover the v7 line, and the introduction puts it simply: "You can add the driver to your application to work with MongoDB in JavaScript or TypeScript." The sections are:
- Get Started and Connect: connection strings, connection options, TLS and connection pooling.
- Databases and collections, CRUD operations and promises.
- Aggregation, indexes and running database commands.
- Data formats: how BSON types such as ObjectId, Decimal128 and dates map to JavaScript.
- Search and vector search for Atlas.
- Monitoring, logging and security, including authentication mechanisms.
- TypeScript: typing collections so that filters and updates are checked at compile time.
- Reference: compatibility tables, upgrade guides and the full API docs.
Driver first, or Mongoose first?
Learn enough of the driver to know what it does, even if your project will use Mongoose. Mongoose depends on this driver, so connection problems, pooling, error codes such as a duplicate key (11000) and transaction behaviour all come from here. Developers who only know Mongoose often struggle the first time they need an aggregation pipeline or a bulk write that the ODM does not wrap neatly. Many teams also skip the ODM entirely and use the driver with TypeScript types and a validation library.
What to read first
- The connection guide, especially the advice to create one
MongoClientand reuse it across your application instead of connecting per request. This matters even more in serverless functions. - CRUD:
insertOne,findwith filters and projections,updateOnewith update operators, andfindOneAndUpdate. - Aggregation, using the same stages you practised in mongosh.
- The TypeScript page, if your project uses TypeScript.
- Transactions and change streams when a feature genuinely needs them.
Prerequisites
Comfort with JavaScript promises and async/await, and basic MongoDB queries in the shell. The current package requires Node.js 20.19.0 or later according to its npm metadata, so check your runtime before upgrading an old project.
Common questions
Why does my query work in mongosh but not in Node.js? Usually an await is missing, an ObjectId is being compared with a string, or a cursor is never converted with toArray(). The CRUD pages cover all three.
Is it free? Yes, open source under Apache 2.0.
What can I do after it? Build a Node.js API on MongoDB with pooled connections, typed collections, correct error handling and aggregation queries.
Best for: JavaScript and TypeScript developers building backends on MongoDB, whether or not they later add an ODM.
Ready to start?
Opens on MongoDB in a new tab.
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
Follow along
New writing, resources and project ideas land here first.