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

Auth.js · Const

FaunaAdapter

FaunaAdapter is Auth.js’s official Fauna adapter. Pass it a Fauna Client and optionally adapter configuration to obtain an Auth.js Adapter.

How it works

FaunaAdapter connects Auth.js to Fauna by accepting a Fauna Client and optional adapter configuration, then returning an Auth.js Adapter. Auth.js uses that adapter to persist authentication data; custom collection names can be supplied through the configuration object.

Syntax

function FaunaAdapter(client, config?): Adapter

Parameters

NameTypeDescription
clientClientFauna client used by the adapter to access the database.
configAdapterConfigOptional adapter configuration, including collection-name overrides.

Returns

Adapter

Key points

  • FaunaAdapter is the official Fauna database adapter for Auth.js and NextAuth.js.
  • Its declaration takes a Fauna client plus optional configuration and produces an Auth.js Adapter.
  • Custom collection names can be provided through the adapter options.

Common mistakes

  • If custom collection names are configured, they must correspond to the collections in the Fauna database.

Example: Configure FaunaAdapter

import NextAuth from "next-auth"
import { Client } from "fauna"
import { FaunaAdapter } from "@auth/fauna-adapter"

const client = new Client({
  secret: process.env.AUTH_FAUNA_SECRET,
  endpoint: new URL(process.env.AUTH_FAUNA_CLIENT!),
})

export const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [],
  adapter: FaunaAdapter(client),
})

Creates a Fauna client from environment variables and supplies it to Auth.js through the adapter.

When to use it

Fauna-backed authentication storage

Persist Auth.js users, accounts, sessions, and verification tokens in Fauna.

Custom collection names

Use a non-default Fauna schema naming convention.

Auth.js integration

Connect a NextAuth.js application to a Fauna database.

Interview questions

QWhat does FaunaAdapter return and what inputs does it accept?

FaunaAdapter is a factory function for the official Fauna integration. It receives a Fauna Client and optionally an AdapterConfig, and returns an Auth.js Adapter.

Follow-up: How would you alter the default database naming? Pass a second configuration argument containing collectionNames for user, account, session, and verificationToken.

QHow is FaunaAdapter typically configured?

Create a Fauna Client with the database secret and endpoint, then pass that client to FaunaAdapter in the Auth.js configuration. The adapter is installed from @auth/fauna-adapter, while the Fauna client comes from fauna.

Follow-up: What must be checked when renaming collections? The configured names need to match the actual Fauna database collections.

QWhat customization does the adapter configuration provide?

The optional configuration supports custom collection names. The documented names cover the user, account, session, and verification-token collections.

Follow-up: Why does the name mapping matter? Auth.js adapter operations target those collections, so mismatches prevent the integration from using the intended database collections.

  • FaunaAccount
  • FaunaSession
  • FaunaUser
  • FaunaVerificationToken
  • AdapterConfig

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