Configure Google, GitHub, and other Better Auth social providers.
This guide shows how to enable social login in starter. Google and GitHub are ready by default, with support for other Better Auth providers.
Set the Client ID and Client Secret from each provider’s developer console.
# Google
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
# GitHub
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=Add providers inside the social object. If a variable is missing, that provider simply won’t load.
export const auth = betterAuth({
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
},
// ... Other providers
},
// ...
});A drop-in component is available for rendering social buttons.
import { GoogleSignInButton } from "@/src/components/auth/social";
<GoogleSignInButton />;Better Auth wires up callbacks automatically. Just ensure the URLs are added in each provider’s dashboard.
Development:
http://localhost:3000/api/auth/callback/googleProduction:
https://your-domain.com/api/auth/callback/google