Skip to content
Migrating from NextAuth.js v4? Read our migration guide.
Getting Started
Adapters
Drizzle

Drizzle ORM Adapter

Resources

Setup

Installation

npm install drizzle-orm @auth/drizzle-adapter
npm install drizzle-kit --save-dev

Environment Variables

DRIZZLE_DATABASE_URL=postgres://postgres:adminadmin@0.0.0.0:5432/db

Configuration

./auth.ts
import NextAuth from "next-auth"
import { DrizzleAdapter } from "@auth/drizzle-adapter"
import { db } from "./schema"
 
export const { handlers, auth, signIn, signOut } = NextAuth({
  adapter: DrizzleAdapter(db),
  providers: [],
})
💡

If you’re using multi-project schemas, you can pass your table function as a second argument

Apply one of the below schema’s to your database to setup the required tables. You may of course extend the schema with additional fields, etc.

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