Social Provider Configuration
Instructions
- •Identify which social providers need to be configured (Google, GitHub, Discord, etc.)
- •Register the application with each provider to get client credentials
- •Add the provider configuration to the Better Auth setup
- •Set up proper redirect URLs
- •Handle provider-specific options
- •Test the social authentication flows
Supported Providers
Better Auth supports multiple social providers including:
- •GitHub
- •Discord
- •Twitter/X
- •Apple
- •And more
Configuration Steps
- •Go to the provider's developer portal and create an application
- •Set the redirect URI to your app's callback URL (typically
/api/auth/callback/[provider]) - •Get the Client ID and Client Secret
- •Add the provider to your Better Auth configuration
- •Add the credentials to environment variables
- •Test the authentication flow
Example Configuration
typescript
import { betterAuth } from "better-auth";
import { google, github } from "better-auth/oauth-providers";
export const auth = betterAuth({
// other options...
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
},
github: {
clientId: process.env.GITHUB_CLIENT_ID!,
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
},
},
});
Provider-Specific Considerations
- •Some providers require domain verification
- •Callback URLs must match exactly what's registered
- •Some providers have special requirements (Apple requires additional configuration)
- •Store credentials securely in environment variables
- •Consider using different credentials for development and production