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

Auth.js · Const

Twitch

Auth.js provides a built-in Twitch OpenID Connect provider. Configure it with Twitch credentials and register its callback URL in the Twitch application console.

How it works

The Twitch provider is an OpenID Connect integration with built-in defaults. Pass optional provider configuration, including the Twitch client ID and secret, to obtain a provider definition for Auth.js.

Syntax

Twitch(config?: OIDCUserConfig<TwitchProfile>): OIDCConfig<TwitchProfile>

Parameters

NameTypeDescription
configOIDCUserConfig<TwitchProfile>Optional OIDC provider settings, including Twitch credentials and other provider overrides.

Returns

OIDCConfig<TwitchProfile>

Key points

  • Auth.js includes Twitch as a built-in provider rather than requiring a custom OAuth implementation.
  • The provider is intended to add Twitch sign-in to an application.
  • The documented environment variable names are AUTH_TWITCH_ID and AUTH_TWITCH_SECRET.
  • The standard callback path ends with /api/auth/callback/twitch.
  • Twitch can be used with Auth.js's supplied defaults before applying any application-specific overrides.
  • The Twitch profile type extends a string-keyed record, allowing profile data beyond explicitly listed properties.

Common mistakes

  • If several redirect URIs are configured in Twitch, the first one receives the redirect.
  • The provider follows Auth.js's OIDC assumptions unless its defaults are customized.

Example: Configure Twitch with Auth.js Core

import { Auth } from "@auth/core"
import Twitch from "@auth/core/providers/twitch"

const request = new Request(origin)
const response = await Auth(request, {
  providers: [
    Twitch({
      clientId: process.env.AUTH_TWITCH_ID,
      clientSecret: process.env.AUTH_TWITCH_SECRET,
    }),
  ],
})

Creates an Auth.js request handler configured with Twitch using the provider's client credentials.

When to use it

Offer Twitch as a social login option.

Application sign-in

Build a request handler with Twitch in the providers list.

Auth.js Core integration

Override the built-in OIDC settings for a specialized deployment.

Provider customization

Interview questions

QHow do you add Twitch authentication in Auth.js Core?

Use the Twitch provider from the Auth.js package for the framework or runtime in use, then include it in the providers configuration. In Core, call Twitch with the client ID and client secret and pass the result to Auth.

Follow-up: How can the built-in behavior be changed? Override the provider's default configuration using Auth.js's built-in provider customization mechanism.

QWhat callback URL must be registered for Twitch?

The callback endpoint is https://example.com/api/auth/callback/twitch for the documented Next.js-style setup. The corresponding redirect URL must also be registered in the Twitch developer console.

Follow-up: What should be checked when the callback fails? Verify that the registered redirect URI exactly matches the application's callback URL and that Twitch is using the intended first URI.

QWhat are Twitch's provider parameter and return types?

The provider accepts an OIDCUserConfig parameter specialized with TwitchProfile and returns an OIDCConfig specialized with TwitchProfile. This lets the provider expose Twitch profile data while retaining the OIDC provider contract.

Follow-up: What profile shape is available? TwitchProfile extends Record<string, any>, so it supports the documented profile fields together with additional indexed properties.

  • TwitchProfile
  • OIDCUserConfig
  • OIDCConfig
  • customizing a built-in OAuth provider

Source: Twitch. Checked 2026-10-15.