Built-in provider setup
Enable a ready-made OAuth integration such as GitHub, Google, or Auth0.
Auth.js · Pipe
providers is the Auth.js configuration array that enables authentication integrations. Add built-in provider definitions or custom OAuth/OIDC provider objects to make them available for sign-in.
Auth.js receives providers through the providers configuration array. Each entry is typically a built-in provider function or a custom provider object; built-ins supply defaults, while custom configuration can override options such as credentials, issuer, or authorization parameters.
NextAuth({ providers: [Provider, ...] })| Name | Type | Description |
|---|---|---|
providers | Provider[] | Array of enabled provider definitions, usually imported built-in providers or custom OAuth/OIDC provider objects. |
No standalone return value; the configured providers become available through Auth.js authentication routes and sign-in flows.
providers array.oidc for OpenID Connect integrations and oauth for OAuth 2 providers.import NextAuth from "next-auth"
import GitHub from "next-auth/providers/github"
export const { handlers, auth } = NextAuth({
providers: [GitHub],
})Import a built-in provider and register it in the Auth.js configuration.
Enable a ready-made OAuth integration such as GitHub, Google, or Auth0.
Adjust scopes, authorization parameters, or other defaults for a built-in provider.
Connect an OAuth 2 or OIDC service that is not included in the built-in catalog.
providers configuration?The providers option is an array in the Auth.js configuration. It contains enabled authentication integrations, such as GitHub, and Auth.js uses those entries to expose the corresponding sign-in options.
Follow-up: How would you customize a built-in provider? Pass options to its provider function; Auth.js merges those options with the built-in defaults.
For a built-in OAuth provider, import the provider from the framework-specific next-auth/providers package and place it in the array. Configuration commonly supplies a client ID and client secret through environment variables.
Follow-up: What if no built-in provider fits? Define a custom provider object with an ID, name, type, issuer or OAuth settings, and client credentials.
A custom provider object must identify itself with an id and name, and specify an OAuth or OIDC type. OIDC providers can use an issuer so Auth.js can discover the provider's configuration.
Follow-up: Why is the provider ID significant? It is used by signIn and becomes part of the callback URL, so changing it affects integration configuration.
OAuth ProvidersConfiguring OAuth ProvidersProviderTypeGitHub ProviderAuthConfig