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

@auth/d1-adapter

An official Cloudflare D1 adapter for Auth.js / NextAuth.js.

Warning

This adapter is not developed or maintained by Cloudflare and they haven’t declared the D1 api stable. The author will make an effort to keep this adapter up to date. The adapter is compatible with the D1 api as of March 22, 2023.

Installation

npm install next-auth @auth/d1-adapter

D1Database

type D1Database: WorkerDatabase | MiniflareD1Database;

D1Adapter()

D1Adapter(db): Adapter

Parameters

ParameterType
dbD1Database

Returns

Adapter


createRecord()

createRecord<RecordType>(
   db, 
   CREATE_SQL, 
   bindings, 
   GET_SQL, 
getBindings): Promise<null | RecordType>

Type parameters

Type parameter
RecordType

Parameters

ParameterType
dbD1Database
CREATE_SQLstring
bindingsany[]
GET_SQLstring
getBindingsany[]

Returns

Promise<null | RecordType>


deleteRecord()

deleteRecord(
   db, 
   SQL, 
bindings): Promise<void>

Parameters

ParameterType
dbD1Database
SQLstring
bindingsany[]

Returns

Promise<void>


getRecord()

getRecord<RecordType>(
   db, 
   SQL, 
bindings): Promise<RecordType | null>

Type parameters

Type parameter
RecordType

Parameters

ParameterType
dbD1Database
SQLstring
bindingsany[]

Returns

Promise<RecordType | null>


up()

up(db): Promise<void>

Parameters

ParameterType
dbD1Database

Returns

Promise<void>


updateRecord()

updateRecord(
   db, 
   SQL, 
bindings): Promise<D1Result<unknown> | D1Result<unknown>>

Parameters

ParameterType
dbD1Database
SQLstring
bindingsany[]

Returns

Promise<D1Result<unknown> | D1Result<unknown>>

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