Adapter account persistence
Implementing an Auth.js database adapter that stores and retrieves linked provider accounts.
Auth.js · Type Alias
AdapterAccount describes an account record managed by an Auth.js adapter. It links a user to a provider and carries the provider-specific account identity used by adapter operations.
AdapterAccount is the adapter-facing account shape for connecting a user with an authentication provider. It includes the provider-specific identity, account kind, and owning user, while also allowing account token data inherited from the broader Account model.
type AdapterAccount = Account & { userId: string }An adapter account record describing a user’s connection to a provider.
import type { AdapterAccount } from "next-auth/adapters"
const account: AdapterAccount = {
provider: "google",
providerAccountId: "user-123",
type: "oauth",
userId: "user-456",
}
export function getAccount(): AdapterAccount {
return account
}This typed object represents an adapter-managed account linked to a user and an authentication provider.
Implementing an Auth.js database adapter that stores and retrieves linked provider accounts.
Typing account data returned by an adapter’s provider-account lookup.
Representing multiple OAuth, OIDC, or email connections for one user.
AdapterAccount is the account type used by Auth.js adapters. It models a provider connection belonging to a user and is returned by adapter operations such as getAccount.
Follow-up: How should getAccount signal that no record exists? It should return null rather than fabricate an AdapterAccount.
An account connects a user to a provider. Auth.js documents OAuth/OIDC and email accounts as account categories, and one user may have several accounts.
Follow-up: Why is provider identity needed? It distinguishes the same user’s separate external or authentication-provider connections.
AdapterAccount is related to Account and carries provider information plus adapter ownership data, including the user associated with the account. Adapter methods use it when reading and writing account records.
Follow-up: Which adapter operation commonly reads it? getAccount takes a provider account ID and provider and returns an AdapterAccount or null.
AccountAdapterAdapterUsergetAccountlinkAccount