Overview of Auth.js Adapters
strategy: "jwt"), a database adapter can be used to persist sessions in a database. Before creating a custom adapter, check the official database adapters list to see if a compatible one already exists.website·Indexed 40 days ago
https://authjs.dev/An open-source authentication solution providing a core set of providers and adapters for frameworks including Next.js (next-auth), Express, SvelteKit, and Qwik. It features a wide array of OAuth providers such as Spotify, Reddit, and Twitter/X, as well as database adapters for TypeORM, Hasura, SurrealDB, and Drizzle.
strategy: "jwt"), a database adapter can be used to persist sessions in a database. Before creating a custom adapter, check the official database adapters list to see if a compatible one already exists.The Forward Email provider enables passwordless sign-in using "magic links." When a user provides their email, a verification token is sent via email. Clicking this link verifies the user's identity and either creates a new account or signs them into an existing one. By default, verification tokens are valid for 24 hours.
Critical Requirement: You must configure a database adapter to use this provider, as it requires a database to store verification tokens. It can be used alone or alongside OAuth providers.
The Postmark provider enables email-based sign-in using 'magic links'. When a user enters their email, a verification token is sent via email. Clicking this link verifies the user's identity and signs them in. If the user is new, an account is created upon first verification; otherwise, they are signed into their existing account. By default, verification tokens are valid for 24 hours.
Critical Requirement: A database adapter must be configured to store verification tokens; email sign-in cannot function without a database.
Auth.js provides a set of framework-specific libraries and database adapters based on the @auth/core library. While most users interact with the framework-specific packages, the core library is intended for library authors.
Framework Support Status:
next-auth): v5 (beta) and v4 (maintenance mode).@auth/qwik): Released.@auth/express): Experimental Release.@auth/sveltekit): Experimental Release.@auth/solid-start): Experimental Release.Database Adapter Support:
@auth/ ext{-adapter} packages for current development. These are fully compatible with next-auth and all @auth/* libraries.@next-auth/ ext{-adapter} packages are no longer maintained; users should migrate to the @auth/* equivalents.The Mailgun provider enables 'magic link' authentication. When a user signs in with their email, a verification token is sent via email. If the user clicks the link within the validity period (default 24 hours), an account is created (if it doesn't exist) and the user is signed in. This provider can be used alongside or instead of OAuth providers.
Critical Requirement: You must configure a database adapter to use the Mailgun provider; it is not possible to enable email sign-in without a database to store verification tokens.
The Nodemailer provider enables passwordless sign-in via "magic links". When a user provides their email, a verification token is sent to that address. If the user clicks the link within the validity period (default 24 hours), an account is created (if it doesn't exist) and the user is signed in.
Critical Requirement: You must configure a database adapter to use the Nodemailer provider, as it requires a database to store verification tokens. It can be used alone or alongside OAuth providers.
next-auth@5.0.0-beta and later, as well as all other frameworks under the @auth/* namespace.@auth/core/jwt module provides functions and types to encode and decode JWTs issued by Auth.js. By default, Auth.js JWTs are encrypted using the A256CBC-HS512 algorithm (JWE). The encryption key is derived from the AUTH_SECRET environment variable or a provided secret property. These JWTs are intended for use by the same application that issued them; for third-party API authentication, the Identity Provider should be used instead.Account entity stores information about the authentication provider used by a user. It implements RemoveIndex<AdapterAccount>.new Account(): Account
// Properties
access_token?: string;
expires_at?: number; // Absolute timestamp in seconds
id: string;
id_token?: string;
provider: string; // e.g., "google"
providerAccountId: string; // OAuth id, email, or credentials id
refresh_token?: string;
scope?: string;
session_state?: JsonValue;
token_type?: Lowercase<string>;
type: AdapterAccountType;
user: User;
userId: string;@auth scope, NextAuth.js remains under the next-auth scope to minimize migration overhead. Other integrations are typically named by their framework (e.g., "SvelteKit Auth" or "Express Auth").