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

Auth.js · Const

Battlenet

BattleNet is Auth.js’s built-in Battle.net OAuth 2 provider. Configure it with a client ID, client secret, and a supported regional issuer.

How it works

BattleNet configures Auth.js to authenticate users through Battle.net's OAuth 2 service. Supply the client credentials and choose a supported regional issuer; Auth.js then uses the provider's built-in endpoints and maps the callback to the Battle.net provider route.

Syntax

BattleNet(options)

Parameters

NameTypeDescription
optionsOAuthUserConfig<P> & { issuer: BattleNetIssuer; }OAuth provider configuration plus a required supported Battle.net issuer.

Returns

A configured Battle.net OAuth provider definition for Auth.js.

Key points

  • Auth.js includes Battle.net as a built-in provider rather than requiring a custom OAuth provider definition.
  • The provider supplies standard OAuth settings automatically, reducing the required configuration.
  • Provide the Battle.net application's client ID when constructing the provider.
  • Provide the corresponding client secret so Auth.js can complete the OAuth exchange.
  • Choose the issuer according to the Battle.net region used by the application.
  • Auth.js treats this integration as OAuth 2 by default, so the standard provider flow is used.

Common mistakes

  • The issuer must be one of the documented regional URLs; an arbitrary Battle.net URL is not accepted.
  • Register this callback URL with the Battle.net application for a standard Next.js deployment.

Example: Configure Battle.net with NextAuth

import NextAuth from "next-auth"
import BattleNet from "next-auth/providers/battlenet"

export const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [BattleNet({
    clientId: process.env.AUTH_BATTLENET_ID!,
    clientSecret: process.env.AUTH_BATTLENET_SECRET!,
    issuer: process.env.AUTH_BATTLENET_ISSUER as
      "https://oauth.battle.net",
  })],
})

Register the Battle.net provider with credentials and an issuer for the target region.

When to use it

Social login

Add Battle.net sign-in to a Next.js Auth.js application.

Regional authentication

Route users through the Battle.net OAuth endpoint matching their region.

Provider customization

Adjust the built-in OAuth settings for an atypical deployment.

Interview questions

QHow do you configure Battle.net in Auth.js?

Use BattleNet from the framework-specific provider package, then pass it in the NextAuth providers array. Configure the client ID, client secret, and a supported issuer.

Follow-up: What determines the issuer value? It selects the Battle.net OAuth endpoint for the application's region, so it must match one of the documented regional URLs.

QWhat callback URL does the provider use?

The provider callback for the Next.js integration is /api/auth/callback/battlenet, and the full URL uses the application's origin. That URL must be configured with the provider.

Follow-up: What would you check if the callback fails? Verify the deployment origin and ensure the registered callback URL exactly matches the generated route.

QWhat protocol and defaults does BattleNet use?

BattleNet is an OAuth 2 provider with a built-in default configuration. Supplying options overrides or completes that configuration for the application.

Follow-up: How could the defaults be changed beyond these options? Use Auth.js's documented customization approach for a built-in OAuth provider.

  • BattleNetProfile
  • BattleNetIssuer
  • OAuthUserConfig
  • Auth
  • providers

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