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

Better Auth · Const

twitch

Better Auth’s Twitch provider enables OAuth sign-in by configuring Twitch credentials under socialProviders.twitch. Clients start the flow with signIn.social({ provider: "twitch" }).

How it works

The Twitch provider is registered under socialProviders with its client ID and secret. After the callback URL is configured in Twitch, the client starts authentication through signIn.social using provider: "twitch".

Syntax

socialProviders: { twitch: { clientId: string, clientSecret: string } }
authClient.signIn.social({ provider: "twitch" })

Parameters

NameTypeDescription
providerstringThe social provider identifier; for Twitch, use the literal value twitch.

Returns

The page does not specify a return value for the Twitch provider configuration or sign-in call.

Key points

  • Twitch authentication requires both a client ID and a client secret.
  • Create or obtain the Twitch OAuth credentials through the Twitch Developer Portal.
  • Add Twitch to the auth instance’s socialProviders configuration.
  • The client ID can be supplied from the TWITCH_CLIENT_ID environment variable.
  • The client secret can be supplied from the TWITCH_CLIENT_SECRET environment variable.
  • Start the browser-based provider flow with the client’s signIn.social function.

Common mistakes

  • The Twitch application must use Better Auth’s callback URL for local development; production should use the application’s deployed URL.
  • Changing the authentication route base path requires updating Twitch’s registered redirect URL.

Example: Configure Twitch sign-in

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

export const auth = betterAuth({
  socialProviders: {
    twitch: {
      clientId: process.env.TWITCH_CLIENT_ID!,
      clientSecret: process.env.TWITCH_CLIENT_SECRET!,
    },
  },
});

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

Configure Twitch with credentials from the Twitch Developer Portal, then start the provider redirect with the client’s social sign-in method.

When to use it

Twitch-based sign-in

Users authenticate through Twitch instead of creating a local password.

Environment-backed OAuth configuration

A server configures provider credentials without embedding secrets in source code.

OAuth callback flow

An application sends users through a provider redirect and receives them at its Better Auth callback route.

Interview questions

QHow do you configure Twitch in Better Auth?

Register Twitch inside the auth instance’s socialProviders configuration. Provide the Twitch client ID and client secret, typically from environment variables.

Follow-up: Where do the credentials come from? They are created in the Twitch Developer Portal, and the application’s callback URL must also be registered there.

QHow does a client start Twitch sign-in?

Use authClient.signIn.social with an object whose provider property is set to "twitch". This begins the Twitch social sign-in flow.

Follow-up: What value identifies Twitch? The provider identifier is the literal string twitch.

QWhat redirect URL does Twitch require?

For local development, configure Twitch to redirect to /api/auth/callback/twitch on the local application host. In production, register the deployed application URL instead.

Follow-up: What must change if auth routes move? The registered redirect URL must be adjusted to reflect the new auth route base path.

  • betterAuth
  • socialProviders
  • signIn.social
  • createAuthClient

Source: Twitch. Checked 2026-10-15.