# davenport

> A CouchDB client for simplifying common tasks like get, list, create, update and delete. Comes complete with full TypeScript definitions.

Latest version **3.0.1** (published 2026-06-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install davenport
pnpm add davenport
yarn add davenport
bun add davenport
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2026-06-14 |
| First published | 2017-01-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 48.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 11 |
| Author | Joshua Harms |
| Maintainers | nozzlegear |
| Keywords | couchdb, client, api, davenport, futon, fauxton, gearworks, typescript |

## Links

- npm: https://www.npmjs.com/package/davenport
- Repository: https://github.com/nozzlegear/davenport
- Homepage: https://github.com/nozzlegear/davenport#readme
- Issues: https://github.com/nozzlegear/davenport/issues
- npm.io page: https://npm.io/package/davenport

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 3.0.1 (latest) — 2026-06-14
- 2.8.2 — 2018-02-22
- 2.8.1 — 2018-02-22
- 2.8.0 — 2017-12-30
- 2.8.0-beta1 — 2017-08-31
- 2.7.1 — 2017-08-28
- 2.7.0 — 2017-08-28
- 2.6.0 — 2017-06-25
- 2.5.1 — 2017-06-24
- 2.5.0 — 2017-06-24
- 2.4.0 — 2017-06-15
- 2.3.0 — 2017-06-10
- 2.2.1 — 2017-05-25
- 2.2.0 — 2017-05-25
- 2.1.1 — 2017-05-25
- … 14 more at https://npm.io/package/davenport/versions

## README

# Davenport

Davenport is a CouchDB client for simplifying common tasks like get, list, create, update and delete. It comes complete with full TypeScript definitions.

## Installing

You can install Davenport with either npm or [Yarn](https://yarnpkg.com):

```bash
npm install davenport --save

# Or use Yarn
yarn add davenport
```

## Importing

Davenport is a pure ESM module. It can be imported via ES6-style default import syntax:

```js
import Client from 'davenport';
```

### Using Davenport in the browser

Davenport can be used in the browser via a bundler like Vite. It uses the native `fetch` API for all requests.

Make sure your CouchDB installation is [configured to allow cross-origin resource sharing (CORS)](https://wiki.apache.org/couchdb/CORS), otherwise Davenport won't be able to connect!

![Enable CORS](https://i.imgur.com/E63QDdh.jpg)

## Async/await and promises

All Davenport functions are implemented as async/awaitable promises. You'll need Node.js v4 and above to use Davenport, as Node v3 and below don't support the generators needed for async/await.

Because async/await implements a promise-like interface in ES6, you can use the functions in this library in two different ways:

With async/await:

```js
//1. async/await
const foo = await client.get(id);

//Do something with the object
```

With promises:

```js
const foo = client.get(id).then((shop) => {
  //Do something with the object.
});
```

Both methods are supported and the results won't differ. The only difference is an `await`ed method will throw an error if the method fails, where a promise would just fail silently unless you use `.catch`.

For the sake of being concise, all examples in this doc will use async/await.

## Client vs configureDatabase

Davenport exports a `configureDatabase` function that can help you create a database, add indexes, set up design documents with views, and then returns a client ready to interact with that database. It will also check that your CouchDB server is at least version 2.0, which is required for many of the functions used by Davenport.

```js
// Configure the database with an index on the 'foo' object property, and a view that lists all foos greater than 5.
const designDoc = {
    name: "list",
    views: [{
        name: "only-foos-greater-than-5",
        map: function (doc: TestObject) {
            if (doc.foo > 5) {
                emit(doc._id, doc);
            }
        }.toString(),
        reduce: "_count"
    }]
}

const client = await configureDatabase(DB_URL, {
    name: "my-foo-database",
    designDocs: [designDoc]
})
```

You don't need to use the `configureDatabase` function to interact with your database, though. If you have no need for setting up design docs or indexes, just instantiate a new `Client` while passing in a database URL and database name.

```js
import Client from 'davenport';

const client = new Client(DB_URL, 'my-foo-database');
```

## Typescript declarations

Using TypeScript? The TypeScript compiler will automatically pull in Davenport definitions for you when you install Davenport, **as long as you're using TypeScript 2+**.

Pass your `CouchDoc` extending interface to the `configureDatabase` and `new Client` functions to get full TypeScript support for all client methods:

```ts
import Client, { CouchDoc } from 'davenport';

interface Foo extends CouchDoc {
  foo: number;
  bar: number;
}

const client = new Client<Foo>(DB_URL, 'my-foo-database');
const myFoo = await client.get(id);

// TypeScript automatically knows that variable `myFoo` is a Foo object.
```

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