Skip to content
Migrating from NextAuth.js v4? Read our migration guide.
API reference
@auth/pouchdb-adapter

@auth/pouchdb-adapter

Official PouchDB adapter for Auth.js / NextAuth.js.

Installation

npm install pouchdb pouchdb-find @auth/pouchdb-adapter

PouchDBAdapterOptions

Configure the adapter

Properties

indexes?

optional indexes: IndexConfig;

Override the default index names.

Default
{
  userByEmail: "nextAuthUserByEmail",
  accountByProviderId: "nextAuthAccountByProviderId",
  sessionByToken: "nextAuthSessionByToken",
  verificationTokenByToken: "nextAuthVerificationRequestByToken"
}

pouchdb

pouchdb: Database<{}>;

Your PouchDB instance, with the pouchdb-find plugin installed.

Example
import PouchDB from "pouchdb"
 
PouchDB
  .plugin(require("pouchdb-adapter-leveldb")) // Or any other adapter
  .plugin(require("pouchdb-find")) // Don't forget the `pouchdb-find` plugin
 
const pouchdb = new PouchDB("auth_db", \{ adapter: "leveldb" \})
 
#### prefixes?
 
```ts
optional prefixes: PrefixConfig;

Override the default prefix names.

Default
{
  user: "USER",
  account: "ACCOUNT",
  session: "SESSION",
  verificationToken: "VERIFICATION-TOKEN"
}

PouchDBAdapter()

PouchDBAdapter(options): Adapter

Parameters

ParameterType
optionsPouchDBAdapterOptions

Returns

Adapter


createIndexes()

createIndexes(pouchdb, indexes?): Promise<void>

Parameters

ParameterType
pouchdbDatabase<{}>
indexes?IndexConfig

Returns

Promise<void>

Auth.js © Balázs Orbán and Team - 2024