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

Auth.js · Const

Netlify

Auth.js includes a built-in Netlify OAuth provider. Register it in the provider list and configure the Netlify client credentials through the documented environment variables or provider options.

How it works

The built-in Netlify provider is added to the Auth.js provider list. In a Next.js application, the provider can use AUTH_NETLIFY_ID and AUTH_NETLIFY_SECRET automatically, while the OAuth callback must point to the documented callback path.

Syntax

function default(config): OAuthConfig<Record<string, any>>

Parameters

NameTypeDescription
configOAuthUserConfig<Record<string, any>>Optional OAuth provider configuration, including client credentials or overrides.

Returns

OAuthConfig<Record<string, any>>

Key points

  • Auth.js supplies Netlify as a built-in provider rather than requiring a custom OAuth provider implementation.
  • The documented environment variables for Netlify are AUTH_NETLIFY_ID and AUTH_NETLIFY_SECRET.
  • Auth.js models Netlify using OAuth 2 behavior.
  • Provider defaults can be overridden through the built-in provider customization mechanism.

Common mistakes

  • The provider already supplies its OAuth defaults; only customize them when your use case requires different settings.
  • The OAuth application must allow the correct production callback URL, using the Netlify provider identifier in the path.

Example: Configure Netlify sign-in

import NextAuth from "next-auth"
import Netlify from "next-auth/providers/netlify"

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

Register the built-in Netlify provider in a NextAuth configuration; Auth.js reads the provider credentials from the documented environment variables.

When to use it

Add Netlify as a sign-in option

Next.js application

Use Netlify's built-in OAuth 2 defaults

OAuth configuration

Override provider defaults when required

Custom OAuth setup

Interview questions

QHow do you add Netlify authentication to a Next.js Auth.js application?

Use the built-in Netlify provider in the providers array. In Next.js, import it from next-auth/providers/netlify and register it as Netlify.

Follow-up: What credentials are needed? Set AUTH_NETLIFY_ID and AUTH_NETLIFY_SECRET, or provide equivalent client credentials when configuring the provider.

QWhat callback URL must be configured for Netlify OAuth?

The callback URL is https://example.com/api/auth/callback/netlify for Next.js applications. Replace the domain with the deployed application's domain.

Follow-up: How does the callback differ outside Next.js? Other documented frameworks use /auth/callback/netlify by default.

QWhat does the Netlify provider factory return and how is it configured?

Netlify is treated as an OAuth 2 provider with built-in defaults. The provider function accepts an OAuthUserConfig<Record<string, any>> and returns an OAuthConfig<Record<string, any>>.

Follow-up: When should the defaults be changed? Pass a configuration object to the provider when the application's OAuth setup needs values different from the built-in configuration.

  • OAuthConfig
  • OAuthUserConfig
  • customizing a built-in OAuth provider
  • AUTH_NETLIFY_ID
  • AUTH_NETLIFY_SECRET

Source: Netlify - Auth.js. Checked 2026-10-15.