Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Auth.js · Function

DrizzleAdapter

DrizzleAdapter connects Auth.js to a supported Drizzle ORM database. Pass the database instance and optionally a custom schema; it returns an Auth.js Adapter.

How it works

DrizzleAdapter connects Auth.js to a Drizzle ORM database and returns an Auth.js Adapter implementation. It infers the supported SQL flavor from the database object and uses the default schema unless a custom schema is supplied as the second argument.

Syntax

function DrizzleAdapter<SqlFlavor>(db, schema?): Adapter

Parameters

NameTypeDescription
dbSqlFlavorA supported Drizzle PostgreSQL, MySQL, or SQLite database instance.
schemaDefaultSchema<SqlFlavor>Optional custom table schema; defaults to the schema for the database flavor.

Returns

Adapter

Key points

  • DrizzleAdapter is the official Drizzle ORM integration for Auth.js and NextAuth.js.
  • Its signature takes a typed Drizzle database and an optional schema, returning an Auth.js Adapter.
  • The generic SQL flavor is constrained to supported PostgreSQL, MySQL, or SQLite Drizzle databases.
  • When provided, the optional schema is typed according to the database flavor.
  • The project must have both Drizzle ORM and Drizzle Kit configured before using the adapter.
  • The runtime dependencies include drizzle-orm and the @auth/drizzle-adapter package.

Common mistakes

  • A sessions table is needed when Auth.js uses database-backed sessions; it is not required for every configuration.
  • Include a verification-tokens table when using a Magic Link provider.
  • Custom table definitions must be passed explicitly when they do not match the adapter's defaults.

Example: Configure DrizzleAdapter

import NextAuth from "next-auth"
import { DrizzleAdapter } from "@auth/drizzle-adapter"
import { db } from "./schema.ts"

export const { handlers, auth, signIn, signOut } = NextAuth({
  adapter: DrizzleAdapter(db),
  providers: [],
})

Pass the configured Drizzle database to the adapter, then assign the resulting adapter in the Auth.js configuration.

When to use it

Drizzle-backed authentication storage

Persist Auth.js users, accounts, and related records with Drizzle ORM.

Supported SQL databases

Use PostgreSQL, MySQL, or SQLite through a typed Drizzle database instance.

Custom schema integration

Map Auth.js to application-specific table definitions.

Interview questions

QWhat does DrizzleAdapter return and what inputs does it accept?

DrizzleAdapter accepts a Drizzle database instance and an optional schema, then returns an Auth.js Adapter. The database type determines the SQL flavor and corresponding default schema.

Follow-up: What should be supplied for non-default tables? Pass the custom schema as the adapter's second argument so Auth.js uses those table definitions.

QHow do you configure DrizzleAdapter in Auth.js?

Install drizzle-orm and @auth/drizzle-adapter, and set up Drizzle ORM and Drizzle Kit before configuring the adapter. The adapter is then provided through the adapter property in NextAuth configuration.

Follow-up: What database setup remains necessary? Create the schema, configure a supported driver and drizzle.config.ts, generate a migration, and apply it.

QWhen are the sessions and verification-tokens tables required?

The optional sessionsTable is needed for the database session strategy. The optional verificationTokensTable is needed when a Magic Link provider is used.

Follow-up: Why might a project omit one of these tables? The relevant Auth.js feature may be using another persistence path or may not be enabled.

  • @auth/drizzle-adapter
  • Adapter
  • DefaultSchema
  • SqlFlavorOptions
  • SQLiteDrizzleAdapter
  • PostgresDrizzleAdapter
  • MySqlDrizzleAdapter

Source: Auth.js | Drizzle Adapter. Checked 2026-10-15.