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

Auth.js · Const

SequelizeAdapter

SequelizeAdapter connects Auth.js to a Sequelize database client and returns an Auth.js Adapter. Install the adapter, Sequelize, and the database driver, then provide the configured client to Auth.js.

How it works

SequelizeAdapter connects Auth.js to a Sequelize database client. Calling it returns an Auth.js Adapter that supplies persistence for users, accounts, sessions, and related authentication data through Sequelize models.

Syntax

SequelizeAdapter(client, options?)

Parameters

NameTypeDescription
clientSequelizeConfigured Sequelize database client used by the adapter.
optionsSequelizeAdapterOptionsOptional Sequelize adapter configuration.

Returns

Adapter

Key points

  • The package is Auth.js's official Sequelize integration.
  • The API exposes a Sequelize adapter options interface for optional configuration.
  • The adapter defines Sequelize models for Auth.js data that is stored in the database.

Common mistakes

  • The adapter does not automatically create the required database tables.
  • Use database migrations to provision tables in production rather than relying on runtime synchronization.
  • Installing Sequelize and the adapter is not sufficient; the selected database driver is a separate dependency.

Example: Configure Auth.js with Sequelize

import NextAuth from "next-auth"
import SequelizeAdapter from "@auth/sequelize-adapter"
import { Sequelize } from "sequelize"

const sequelize = new Sequelize(process.env.DATABASE_URL!)

export const { handlers, auth } = NextAuth({
  providers: [],
  adapter: SequelizeAdapter(sequelize),
})

Creates a Sequelize client from the database URL and supplies the resulting adapter to Auth.js.

When to use it

Persist authentication data

An Auth.js application needs persistent users, accounts, and sessions in a Sequelize-supported database.

Integrate with an existing Sequelize setup

A project already uses Sequelize and wants Auth.js to reuse its configured database connection.

Use migrations for the authentication schema

A team needs Auth.js tables managed predictably across deployment environments.

Interview questions

QWhat does SequelizeAdapter do?

SequelizeAdapter is a factory that accepts a Sequelize client and returns an Auth.js Adapter. Auth.js then uses that adapter to persist authentication data through Sequelize.

Follow-up: What must be supplied to the factory? A configured Sequelize instance, typically initialized with the application database connection string.

QWhat parameters does SequelizeAdapter accept?

Its required parameter is client, whose type is Sequelize. An optional options parameter can customize adapter behavior.

Follow-up: Why pass a client instead of a connection string? The adapter relies on the already configured Sequelize instance and its database dialect, connection, and models.

QHow should the database schema be provisioned?

The adapter package does not create database tables by default. Production deployments should create the required schema with migrations; development can use sequelize.sync().

Follow-up: What is the tradeoff of sequelize.sync()? It is convenient for development, but migrations provide controlled and repeatable schema changes for production.

  • @auth/sequelize-adapter
  • SequelizeAdapterOptions
  • Adapter
  • Sequelize
  • Account
  • Session
  • User
  • VerificationToken

Source: Sequelize Adapter. Checked 2026-10-15.