A fork of the official MongoDB Node.js driver that replaces the default TCP socket transport with WebSockets, enabling MongoDB connections in browser environments and environments where traditional TCP connections are restricted. Version 0.0.13 is the current release; the package is experimental and maintained irregularly. It packages the MongoDB driver bundle via Webpack for browser use and requires pnpm for development. Differs from the official driver by patching the transport layer to use WebSocket, which introduces latency and reduced performance compared to native TCP.
npm install mongodb-websocketsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates connecting to MongoDB via WebSocket, inserting a document, and closing the client. Uses async/await and error handling.
Test thoroughly with your use case; fall back to official driver if features are missing.
Monitor official driver updates; consider using native TCP if available.
Use pnpm install (not npm or yarn).
Run pnpm run webpack to produce a browser bundle.
Upgrade Node.js to 14.20.1 or later.
Run pnpm install mongodb-websockets (ensure using pnpm, not npm).
Use import { MongoClient } from 'mongodb-websockets'.Use Node.js >=18 which has global WebSocket, or install 'ws' package and polyfill.
Verify MONGODB_URI or default uri, ensure mongod is running.