Skip to main content

Module: adapters

The @auth/core/adapters module contains useful helpers that a database adapter can incorporate in order to be compatible with Auth.js. You can think of an adapter as a way to normalize database implementation details to a common interface that Auth.js can use to interact with the database.

Auth.js supports 2 session strtategies to persist the login state of a user. The default is to use a cookie + JWT based session store (strategy: "jwt"), but you can also use a database adapter to store the session in a database.

Note

Auth.js currently does not implement federated logout. So even if the session is deleted from the database, the user will still be logged in to the provider. See this discussion for more information.

Installation​

npm install @auth/core

Usage​

Built-in adapters already implement this interface, so you likely won't need to implement it yourself. If you do, you can use the following example as a starting point.

// src/your-adapter.ts
import { type Adapter } from "@auth/core/adapters"

export function MyAdapter(options: any): Adapter {
// implement the adapter methods
}

// src/index.ts
import { MyAdapter } from "./your-adapter"

const response = Auth({
adapter: MyAdapter({ ...adapter options }),
... auth options
})

Type Aliases​

Interfaces​