Relay MongoDB queries over HTTP REST, designed for edge and serverless environments. Current stable version is 1.12.0. Package is actively maintained with semantic-release. It acts as a drop-in replacement for the MongoDB Node.js driver, proxying queries to a server endpoint running near your database. Unlike MongoDB's Atlas REST API, this uses a custom relay with fixed pricing. Supports basic CRUD operations, caching via Next.js/Vercel Data Cache, and streaming. Requires bson@6.2.0 and mongodb@6.2.0 as peer dependencies. Ships TypeScript types.
npm install mongodb-rest-relayNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to use MongoClient and ObjectId from the package to perform basic CRUD via the relay.
Check the supported operations list; for complex aggregations, use the native MongoDB driver directly.
Set the same password environment variable on both ends.
Pin version or review changelog before upgrading.
Deploy the relay server (express/next) on a serverless function or server near your database.
Either set { browser: { crypto: false } } in package.json or use ObjectId from mongodb-rest-relay.Ensure MongoClient is imported from 'mongodb-rest-relay' and RELAY_URL env var is set.
Set MONGODB_RELAY_PASSWORD to the same value on both client and server processes.
Only import from 'mongodb-rest-relay/lib/server/express' on the server-side (not in edge functions).