Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.
Guide · Web DevelopmentFree

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.

GitHub stars

10.2k (node-mongodb-native)

GitHub · Sept 2026

Latest release

7.6.0 (August 2026)

GitHub · Sept 2026

Weekly npm downloads

16.7M (week to 26 Sept 2026)

npm · Sept 2026

Node.js required

20.19.0 or later

npm · Sept 2026

Format

Guide

Topic

Web Development

Provider

MongoDB

Time needed

A weekend for the core, then reference

Level

Intermediate

Access

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

  1. The connection guide, especially the advice to create one MongoClient and reuse it across your application instead of connecting per request. This matters even more in serverless functions.
  2. CRUD: insertOne, find with filters and projections, updateOne with update operators, and findOneAndUpdate.
  3. Aggregation, using the same stages you practised in mongosh.
  4. The TypeScript page, if your project uses TypeScript.
  5. 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.

databasebackendnodejsjavascripttypescript

Ready to start?

Opens on MongoDB in a new tab.

Open resource
Link broken or out of date?

Report a problem

With "MongoDB Node.js Driver Documentation". Only Tauseef reads this.

Work with me

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.