Create new

Social Login

GitHub and Google OAuth — configured and ready. Add more providers in a few lines.

launch.now ships with GitHub and Google pre-configured. Both providers follow the same pattern: create an OAuth app, copy the credentials into .env, add the provider to auth.ts.


Configuration

import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";

export const auth = betterAuth({
  // ...
  socialProviders: {
    github: {
      clientId: process.env.GITHUB_CLIENT_ID!,
      clientSecret: process.env.GITHUB_CLIENT_SECRET!,
    },
    google: {
      clientId: process.env.GOOGLE_CLIENT_ID!,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
    },
  },
});
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=

Setting up GitHub

Create an OAuth App

Go to github.com/settings/developersOAuth AppsNew OAuth App.

Fill in:

  • Application name — anything, e.g. My App (dev)
  • Homepage URLhttp://localhost:3000
  • Authorization callback URLhttp://localhost:3000/api/auth/callback/github

Create two separate apps — one for development (localhost:3000) and one for production (your real domain). GitHub doesn't support multiple callback URLs per app.

Copy the credentials

After creating the app, copy Client ID. Then click Generate a new client secret and copy it immediately — GitHub only shows it once.

GITHUB_CLIENT_ID=Ov23liXXXXXXXXXXXXXX
GITHUB_CLIENT_SECRET=your_secret_here

Update the callback URL for production

In your production OAuth App settings, update the callback URL to:

https://yourdomain.com/api/auth/callback/github

Setting up Google

Create a project in Google Cloud Console

Go to console.cloud.google.com → create a new project (or select an existing one).

Enable the OAuth consent screen

Navigate to APIs & ServicesOAuth consent screen.

  • Choose External (works for any Google account)
  • Fill in app name, support email, and developer email
  • Add the scope userinfo.email and userinfo.profile
  • Add your email as a test user while in development

While your app is in Testing mode, only the test users you add can sign in with Google. Publish the app when you're ready to go live.

Create OAuth credentials

Go to APIs & ServicesCredentialsCreate CredentialsOAuth client ID.

  • Application type: Web application
  • Authorized redirect URIs:
    • http://localhost:3000/api/auth/callback/google (dev)
    • https://yourdomain.com/api/auth/callback/google (prod)

Unlike GitHub, Google supports multiple redirect URIs per app — add both at once.

Copy the credentials

GOOGLE_CLIENT_ID=123456789-xxxx.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-xxxxxxxxxxxx

Signing in from the client

Both providers use the same signIn.social call. The provider name matches the key in socialProviders.

import { authClient } from "@/lib/auth-client";

await authClient.signIn.social({
  provider: "github", // or "google"
  callbackURL: "/dashboard",
});

Account linking

If a user signs up with email/password and later signs in with GitHub using the same email, Better Auth links the accounts automatically.

export const auth = betterAuth({
  // ...
  account: {
    accountLinking: {
      enabled: true,
      trustedProviders: ["github", "google"],
    },
  },
});

trustedProviders tells Better Auth which OAuth providers can auto-link without asking the user to confirm. Only list providers that verify email addresses (GitHub and Google both do).


Adding more providers

Better Auth supports Discord, Twitter/X, Apple, Microsoft, Spotify, and more. The pattern is identical — add credentials to .env and a key to socialProviders:

socialProviders: {
  github: {
    clientId: process.env.GITHUB_CLIENT_ID!,
    clientSecret: process.env.GITHUB_CLIENT_SECRET!
  },
  google: {
    clientId: process.env.GOOGLE_CLIENT_ID!,
  clientSecret: process.env.GOOGLE_CLIENT_SECRET!
  },
  discord: {
    clientId: process.env.DISCORD_CLIENT_ID!,
    clientSecret: process.env.DISCORD_CLIENT_SECRET!
  },
},

Full list of supported providers: better-auth.com/docs/authentication/.