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

Auth.js · Const

SupabaseAdapter

SupabaseAdapter creates an Auth.js adapter backed by a Supabase database. Provide the database URL and access secret, then register the result in Auth.js configuration.

How it works

SupabaseAdapter receives the Supabase database URL and a secret, then returns an Auth.js Adapter that persists user and session data in Supabase. The integration uses a separate next_auth schema and is independent of Supabase Auth.

Syntax

function SupabaseAdapter(options): Adapter

Parameters

NameTypeDescription
optionsSupabaseAdapterOptionsSupabase URL and secret used to access the database.

Returns

Adapter

Key points

  • SupabaseAdapter connects Auth.js or NextAuth.js to Supabase as its persistence layer.
  • The factory accepts one options object and produces an Auth.js Adapter.
  • The secret authorizes the adapter to access the Supabase database.
  • The URL identifies which Supabase database the adapter should use.
  • Install the Supabase client package together with the Auth.js adapter package.

Common mistakes

  • Do not assume Supabase officially maintains or supports this adapter.
  • Expect Auth.js data in the separate next_auth schema rather than in Supabase Auth's data model.
  • This adapter does not provide integration with Supabase Auth itself.

Example: Configure the Supabase adapter

import NextAuth from "next-auth";
import { SupabaseAdapter } from "@auth/supabase-adapter";

export const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [],
  adapter: SupabaseAdapter({
    url: process.env.SUPABASE_URL!,
    secret: process.env.SUPABASE_SERVICE_ROLE_KEY!,
  }),
});

Creates an Auth.js configuration whose adapter stores authentication data in Supabase.

When to use it

Supabase-backed authentication storage

Persisting Auth.js users and sessions in Supabase.

NextAuth.js adapter integration

Adding database persistence to a NextAuth.js application.

Standalone Auth.js server

Using Auth.js with Supabase without using Supabase Auth.

Interview questions

QWhat does SupabaseAdapter return and what configuration does it require?

SupabaseAdapter is a factory function that accepts SupabaseAdapterOptions and returns an Adapter. Its options include the database URL and a secret used to grant database access.

Follow-up: Where does it store Auth.js data? It uses the Supabase Database in a separate next_auth schema, rather than interfacing with Supabase Auth.

QHow would you configure SupabaseAdapter in a Next.js Auth.js application?

Install @supabase/supabase-js and @auth/supabase-adapter, then pass the Supabase URL and service-role key through SupabaseAdapter in the Auth.js configuration. The adapter is supplied through the adapter property.

Follow-up: What security concern follows from this setup? The secret grants database access, so it should be supplied through protected server-side environment variables rather than exposed to clients.

QHow does this adapter differ from Supabase Auth?

It stores user and session data in Supabase, but it is a standalone Auth server and does not interface with Supabase Auth. Supabase Auth is the alternative when its additional authentication features are required.

Follow-up: Which alternative should be considered for built-in email, phone, or MFA support? Use Supabase Auth with the Auth Helpers for Next.js.

  • SupabaseAdapterOptions
  • Adapter
  • @auth/supabase-adapter
  • @supabase/supabase-js

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