# mongodb-connection-string-url

> MongoDB connection strings, based on the WhatWG URL API

Latest version **7.0.2** (published 2026-07-15) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install mongodb-connection-string-url
pnpm add mongodb-connection-string-url
yarn add mongodb-connection-string-url
bun add mongodb-connection-string-url
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 7.0.2 |
| Published | 2026-07-15 |
| First published | 2021-06-15 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20.19.0 |
| Dependencies | 2 |
| Unpacked size | 38 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 11 |
| Maintainers | dbx-node, dariakp, addaleax |
| Keywords | password, prompt, tty |

## Links

- npm: https://www.npmjs.com/package/mongodb-connection-string-url
- Repository: https://github.com/mongodb-js/mongodb-connection-string-url
- Issues: https://github.com/mongodb-js/mongodb-connection-string-url/issues
- npm.io page: https://npm.io/package/mongodb-connection-string-url

## Dependencies (2)

- [whatwg-url](https://npm.io/package/whatwg-url.md) ^14.1.0
- [@types/whatwg-url](https://npm.io/package/@types/whatwg-url.md) ^13.0.0

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 7.0.2 (latest) — 2026-07-15
- 4.0.0-alpha (alpha) — 2025-10-21
- 7.0.1 — 2026-01-26
- 7.0.0 — 2025-11-05
- 3.0.2 — 2025-01-14
- 3.0.1 — 2024-05-10
- 3.0.0 — 2023-11-02
- 2.6.0 — 2022-11-28
- 2.5.4 — 2022-09-30
- 2.5.3 — 2022-07-22
- 2.5.2 — 2022-02-25
- 2.5.1 — 2022-02-23
- 2.5.0 — 2022-02-23
- 2.4.2 — 2022-02-02
- 2.4.1 — 2021-12-21
- … 13 more at https://npm.io/package/mongodb-connection-string-url/versions

## README

# mongodb-connection-string-url

MongoDB connection strings, based on the WhatWG URL API

```js
import ConnectionString from 'mongodb-connection-string-url';

const cs = new ConnectionString('mongodb://localhost');
cs.searchParams.set('readPreference', 'secondary');
console.log(cs.href); // 'mongodb://localhost/?readPreference=secondary'
```

## Deviations from the WhatWG URL package

- URL parameters are case-insensitive
- The `.host`, `.hostname` and `.port` properties cannot be set, and reading
  them does not return meaningful results (and are typed as `never`in TypeScript)
- The `.hosts` property contains a list of all hosts in the connection string
- The `.href` property cannot be set, only read
- There is an additional `.isSRV` property, set to `true` for `mongodb+srv://`
- There is an additional `.clone()` utility method on the prototype

## LICENSE

Apache-2.0

---
_Source: https://npm.io/package/mongodb-connection-string-url · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
