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

Auth.js · Const

Discord

Discord is a built-in Auth.js OAuth provider. Call it with a Discord client ID and secret, then include the returned configuration in Auth.js’s providers list.

How it works

Calling Discord with OAuth client credentials produces a provider configuration that Auth.js can include in its providers list. Auth.js supplies Discord’s standard OAuth settings automatically, while the callback endpoint must be registered as https://example.com/api/auth/callback/discord.

Syntax

Discord<P extends DiscordProfile>(options: OAuthUserConfig<P>): OAuthConfig<P>

Parameters

NameTypeDescription
optionsOAuthUserConfig<P>OAuth configuration for the Discord provider, including the client credentials; generic profile type P extends DiscordProfile.

Returns

OAuthConfig<P>

Key points

  • Use the Discord provider factory to add Discord sign-in to an Auth.js application.
  • Register the Discord-specific callback endpoint at the documented callback URL pattern.
  • Pass the Discord application’s client ID in the provider options.
  • Pass the Discord application’s client secret alongside the client ID.
  • The provider includes standard settings, so a basic integration does not need to define OAuth endpoints manually.

Common mistakes

  • Discord is configured as an OAuth 2 provider by default; customize the built-in configuration only when your use case requires it.

Example: Configure Discord with Auth.js

import { Auth } from "@auth/core"
import Discord from "@auth/core/providers/discord"

const response = await Auth(new Request(origin), {
  providers: [
    Discord({
      clientId: process.env.DISCORD_CLIENT_ID!,
      clientSecret: process.env.DISCORD_CLIENT_SECRET!,
    }),
  ],
})

Creates an Auth.js request handler configured with Discord OAuth credentials.

When to use it

Discord sign-in

Users authenticate through their Discord accounts in an Auth.js application.

Use provider defaults

An application needs a standard OAuth setup without manually specifying Discord endpoints.

Typed user profiles

A project needs Discord profile data represented with a typed profile shape.

Interview questions

QHow do you add Discord authentication to Auth.js?

The Discord factory accepts OAuth user configuration and returns an OAuth provider configuration. Add its result to the Auth.js providers array with the Discord client ID and client secret.

Follow-up: What callback URL should be registered? Use https://example.com/api/auth/callback/discord, matching the provider identifier.

QWhich options are required in the documented setup?

The provider has built-in defaults, so the normal setup only supplies clientId and clientSecret. Auth.js then uses the resulting configuration during the OAuth flow.

Follow-up: How would you change a built-in default? Follow Auth.js’s customization approach for overriding a built-in OAuth provider.

QWhat are the Discord provider’s parameter and return types?

The provider function is generic over a profile type extending DiscordProfile. It accepts OAuthUserConfig<P> and returns OAuthConfig<P>, allowing the provider configuration to preserve the profile type.

Follow-up: What does DiscordProfile represent? It corresponds to Discord’s documented user structure and also permits additional string-keyed values.

  • DiscordProfile
  • OAuthUserConfig
  • OAuthConfig
  • Auth
  • customizing a built-in OAuth provider

Source: Discord | Auth.js. Checked 2026-10-15.