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

Better Auth · Const

github

Better Auth's GitHub provider connects OAuth sign-in to a GitHub application. Configure client credentials under socialProviders.github, then invoke signIn.social with provider set to github.

How it works

Better Auth enables GitHub by placing the provider credentials under the auth instance's socialProviders configuration. The client then calls signIn.social with provider set to github, which begins the OAuth sign-in flow.

Syntax

betterAuth({ socialProviders: { github: { clientId, clientSecret } } })
authClient.signIn.social({ provider: "github" })

Parameters

NameTypeDescription
providerstringConfigured social provider name; for this card it must be github.

Returns

The documentation shows the awaited signIn.social call but does not specify a return type.

Key points

  • GitHub authentication requires an application client ID and client secret.
  • Enable GitHub by adding its configuration to the auth instance's socialProviders option.
  • The client sign-in method accepts an options object.
  • Set the sign-in options provider field to github.

Common mistakes

  • Configure the GitHub application's local redirect URL as the callback path shown in the documentation; use your application URL in production.
  • The GitHub app must request the user:email scope.
  • In GitHub app settings, grant read-only access to email addresses.

Example: Configure GitHub sign-in

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

export const auth = betterAuth({
  socialProviders: {
    github: {
      clientId: process.env.GITHUB_CLIENT_ID as string,
      clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
    },
  },
});

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

Configure GitHub with application credentials, then start the client-side social sign-in flow.

When to use it

Social login

Users authenticate through GitHub instead of creating a local password.

OAuth identity integration

An application needs GitHub identity data while keeping OAuth configuration in Better Auth.

Environment-specific setup

A team enables GitHub sign-in in development before deploying the production callback URL.

Interview questions

QHow do you configure GitHub sign-in?

Register a GitHub application and provide its client ID and client secret in the github entry of socialProviders. The client can then call signIn.social with provider set to github.

Follow-up: What callback should local development use? Use http://localhost:3000/api/auth/callback/github, while production should use the application's URL.

QWhat does signIn.social receive for GitHub?

The provider value identifies which configured social provider starts the flow, so it must be github for this integration. The call is made through the client returned by createAuthClient.

Follow-up: What additional GitHub permission is required? The app must include the user:email scope and grant read-only email access.

QWhich credentials are required?

The GitHub app needs both a client ID and client secret. These values are passed to Better Auth through environment variables in the provider configuration.

Follow-up: Where are the credentials obtained? They come from the GitHub Developer Portal after creating the application.

  • socialProviders
  • signIn.social
  • createAuthClient
  • clientId
  • clientSecret
  • user:email

Source: GitHub | Better Auth. Checked 2026-10-15.