Offer Twitch as a social login option.
Application sign-in
Auth.js · Const
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.
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.
Twitch(config?: OIDCUserConfig<TwitchProfile>): OIDCConfig<TwitchProfile>| Name | Type | Description |
|---|---|---|
config | OIDCUserConfig<TwitchProfile> | Optional OIDC provider settings, including Twitch credentials and other provider overrides. |
OIDCConfig<TwitchProfile>
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.
Application sign-in
Auth.js Core integration
Provider customization
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.
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.
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.
TwitchProfileOIDCUserConfigOIDCConfigcustomizing a built-in OAuth provider