Skip to content
Migrating from NextAuth.js v4? Read our migration guide.
API reference
@auth/azure-tables-adapter

@auth/azure-tables-adapter

An official Azure Table Storage adapter for Auth.js / NextAuth.js.

Installation

npm install next-auth @auth/azure-tables-adapter

keys

const keys: {
  account: "account";
  accountByUserId: "accountByUserId";
  session: "session";
  sessionByUserId: "sessionByUserId";
  user: "user";
  userByEmail: "userByEmail";
  verificationToken: "verificationToken";
};

Type declaration

account

account: string = "account";

accountByUserId

accountByUserId: string = "accountByUserId";

session

session: string = "session";

sessionByUserId

sessionByUserId: string = "sessionByUserId";

user

user: string = "user";

userByEmail

userByEmail: string = "userByEmail";

verificationToken

verificationToken: string = "verificationToken";

TableStorageAdapter()

TableStorageAdapter(client): Adapter
  1. Create a table for authentication data, auth in the example below.
auth.ts
import type { AuthConfig } from "next-auth"
import { TableStorageAdapter } from "@next-auth/azure-tables-adapter"
import { AzureNamedKeyCredential, TableClient } from "@azure/data-tables"
 
const credential = new AzureNamedKeyCredential(
  process.env.AZURE_ACCOUNT,
  process.env.AZURE_ACCESS_KEY
)
const authClient = new TableClient(
  process.env.AZURE_TABLES_ENDPOINT,
  "auth",
  credential
)
 
// For more information on each option (and a full list of options) go to
// https://authjs.dev/reference/core/types#authconfig
export default const authConfig = {
  // https://authjs.dev/getting-started/authentication/oauth
  providers: [
    // ...
  ],
  adapter: TableStorageAdapter(authClient),
  // ...
} satisfies AuthConfig

Environment variable are as follows:

AZURE_ACCOUNT=storageaccountname
AZURE_ACCESS_KEY=longRandomKey
AZURE_TABLES_ENDPOINT=https://$AZURE_ACCOUNT.table.core.windows.net

Parameters

ParameterType
clientTableClient

Returns

Adapter


withoutKeys()

withoutKeys<T>(entity): T

Type parameters

Type parameter
T

Parameters

ParameterType
entityGetTableEntityResponse<TableEntityResult<T>>

Returns

T

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