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

Auth.js · Const

Salesforce

Auth.js includes Salesforce as a built-in OAuth/OIDC provider. Add it to the provider list, set the Salesforce client credentials, and register the documented callback URL in Salesforce.

How it works

Salesforce is a built-in OAuth/OIDC provider. Add the provider to Auth.js, configure the Salesforce client credentials through the documented environment variables, and register Auth.js’s callback URL in Salesforce.

Syntax

Salesforce

Key points

  • Auth.js supplies Salesforce as a built-in provider rather than requiring a custom OAuth implementation.
  • Set the Salesforce client ID and secret using the provider-specific environment variable names.
  • The Next.js callback endpoint follows Auth.js’s API callback route and includes the Salesforce provider ID.
  • The built-in defaults handle the standard provider configuration for the normal integration path.

Example: Configure Salesforce with NextAuth

import NextAuth from "next-auth"
import Salesforce from "next-auth/providers/salesforce"

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

Registers Salesforce as a built-in Auth.js provider; credentials are read from the documented environment variables.

When to use it

Offer Salesforce login in a Next.js application

User sign-in

Connect an Auth.js application to Salesforce user accounts

Enterprise identity

Add Salesforce alongside other built-in Auth.js providers

Multi-provider authentication

Interview questions

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

Use the built-in Salesforce provider in the Auth.js providers list. In a Next.js setup, import it from next-auth/providers/salesforce and pass Salesforce to NextAuth({ providers: [...] }).

Follow-up: What configuration is needed beyond the provider declaration? Define AUTH_SALESFORCE_ID and AUTH_SALESFORCE_SECRET, then register the correct callback URL with Salesforce.

QWhich environment variables does the Salesforce provider use?

The documented environment variables are AUTH_SALESFORCE_ID and AUTH_SALESFORCE_SECRET. Auth.js uses these values for the Salesforce client configuration.

Follow-up: How would you customize provider behavior? Call the provider function with options and override the defaults, which Auth.js deeply merges with the built-in configuration.

QWhat callback URL must be configured for Salesforce?

For Next.js, the callback URL is https://example.com/api/auth/callback/salesforce. This URL must also be entered as the redirect URI in the Salesforce application settings.

Follow-up: What changes for other integrations? The provider page documents /auth/callback/salesforce for Qwik and SvelteKit, while the Next.js path includes /api.

  • OIDCConfig
  • SalesforceProfile
  • customizing a built-in OAuth provider
  • AUTH_SALESFORCE_ID
  • AUTH_SALESFORCE_SECRET

Source: Salesforce Provider. Checked 2026-10-15.