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

Better Auth · Const

discord

discord is Better Auth's provider identifier for Discord OAuth. Configure it under socialProviders with Discord credentials, then pass it as the provider value to signIn.social.

How it works

The discord constant is the provider identifier used in Better Auth's socialProviders configuration and in the client's signIn.social call. The server configuration supplies Discord credentials, while the client value selects Discord for the OAuth sign-in flow.

Syntax

provider: "discord"

Parameters

NameTypeDescription
providerstringThe configured social provider identifier; use the literal value discord.

Returns

A social sign-in operation that initiates Discord OAuth through the configured client.

Key points

  • Discord sign-in requires both credentials in the provider configuration.
  • Create or retrieve the OAuth credentials through Discord's Developer Portal.
  • Register Discord by placing its configuration under the auth instance's socialProviders option.
  • Start authentication with the client social sign-in method, passing an options object.
  • Set the request's provider field to the literal identifier discord.
  • When using Discord's bot scope, permissions may be supplied as a bitwise combination or one permission value.

Common mistakes

  • Register the documented callback URL for local development; production should use your application's URL.
  • Changing the authentication route base path requires updating Discord's registered redirect URL.
  • Bot-scope permissions are configured separately through the provider's permissions option.

Example: Configure Discord sign-in

import { betterAuth } from "better-auth";
import { createAuthClient } from "better-auth/client";

export const auth = betterAuth({
  socialProviders: {
    discord: {
      clientId: process.env.DISCORD_CLIENT_ID!,
      clientSecret: process.env.DISCORD_CLIENT_SECRET!,
    },
  },
});

const authClient = createAuthClient();
await authClient.signIn.social({ provider: "discord" });

Configure Discord on the server, then start the provider redirect from the client.

When to use it

OAuth sign-in

An application wants users to authenticate through Discord.

Provider configuration

A server needs to register Discord alongside other social providers.

Bot permissions

A Discord integration requests the OAuth bot scope.

Interview questions

QWhere is discord used in a Better Auth integration?

discord identifies Discord in both places: the server's socialProviders object and the client's signIn.social request. The client request uses { provider: "discord" } to select that configured provider.

Follow-up: How would you support Discord bot permissions? Add the provider's permissions option when using the bot scope, supplying either a bitwise combination or a specific permission value.

QWhat configuration is needed before calling Discord sign-in?

The server configuration requires clientId and clientSecret under socialProviders.discord. The client then calls authClient.signIn.social with the provider set to discord.

Follow-up: What must be changed after moving the auth routes? Update the Discord redirect URL to match the new auth route base path.

QWhat redirect URL requirement should developers verify?

Discord OAuth requires a registered redirect URL. For local development, the documented callback is http://localhost:3000/api/auth/callback/discord; production should use the application's URL.

Follow-up: What if the application uses a custom auth route base path? Register the callback URL derived from that new base path instead of the default.

  • socialProviders
  • signIn.social
  • clientId
  • clientSecret
  • permissions
  • createAuthClient

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