Twitch-based sign-in
Users authenticate through Twitch instead of creating a local password.
Better Auth · Const
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" }).
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".
socialProviders: { twitch: { clientId: string, clientSecret: string } }
authClient.signIn.social({ provider: "twitch" })| Name | Type | Description |
|---|---|---|
provider | string | The social provider identifier; for Twitch, use the literal value twitch. |
The page does not specify a return value for the Twitch provider configuration or sign-in call.
socialProviders configuration.TWITCH_CLIENT_ID environment variable.TWITCH_CLIENT_SECRET environment variable.signIn.social function.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.
Users authenticate through Twitch instead of creating a local password.
A server configures provider credentials without embedding secrets in source code.
An application sends users through a provider redirect and receives them at its Better Auth callback route.
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.
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.
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.
betterAuthsocialProviderssignIn.socialcreateAuthClient