Skip to content
Migrating from NextAuth.js v4? Read our migration guide.
Getting StartedAdaptersAzure Tables

Azure Table Storage Adapter

Resources

Setup

Installation

npm install @auth/azure-tables-adapter

Environment Variables

AUTH_AZURE_ACCOUNT=storageaccountname
AUTH_AZURE_ACCESS_KEY=longRandomKey
AUTH_AZURE_TABLES_ENDPOINT=https://$AZURE_ACCOUNT.table.core.windows.net

Configuration

  1. Create a table for authentication data, auth in the example below.
./auth.ts
import NextAuth, { type AuthConfig } from "next-auth"
import { TableStorageAdapter } from "@auth/azure-tables-adapter"
import { AzureNamedKeyCredential, TableClient } from "@azure/data-tables"
 
const credential = new AzureNamedKeyCredential(
  process.env.AUTH_AZURE_ACCOUNT,
  process.env.AUTH_AZURE_ACCESS_KEY
)
const authClient = new TableClient(
  process.env.AUTH_AZURE_TABLES_ENDPOINT,
  "auth",
  credential
)
 
export const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [],
  adapter: TableStorageAdapter(authClient),
} satisfies AuthConfig)
Auth.js © Balázs Orbán and Team - 2024