Skip to main content
Better Auth supports OAuth 2.0 / OIDC-based social sign-in out of the box. Configure the providers you need in your server config, then call signIn.social on the client.

Supported providers

The following providers are natively supported and can be configured directly in socialProviders: For providers not in this list, use the Generic OAuth plugin.

Configure social providers

Add the providers you need to the socialProviders object in your betterAuth config. Each provider requires a clientId and clientSecret obtained from the provider’s developer console.
auth.ts
Set the baseURL (or BETTER_AUTH_URL env var) to avoid redirect_uri_mismatch errors. Better Auth uses it to construct the OAuth callback URL sent to each provider.

Callback URL

The callback URL for each provider follows the pattern:
Register this URL in each provider’s developer console. For production, replace http://localhost:3000 with your app’s domain. For example:
  • Google: https://example.com/api/auth/callback/google
  • GitHub: https://example.com/api/auth/callback/github
If you change the Better Auth base path, update the callback URL accordingly.

Sign in with a social provider

Call signIn.social on the client, specifying the provider:
sign-in.ts
By default, calling signIn.social redirects the user to the provider’s authorization page. After the user authenticates, they are redirected back to callbackURL.

Sign in with an ID token or access token

If you already have a token from the provider (for example from Google One Tap or a mobile SDK), pass it directly — no redirect occurs:
sign-in-id-token.ts

Requesting additional scopes

Specify scopes in the provider config to request OAuth scopes beyond the defaults:
auth.ts
You can also request additional scopes after sign-in using linkSocial:
request-scopes.ts

Provider-specific options

Google

auth.ts

GitHub

auth.ts
GitHub does not issue refresh tokens for OAuth apps. Access tokens remain valid indefinitely unless explicitly revoked or unused for a year.If you use a GitHub App (not an OAuth App), go to Permissions and Events > Account Permissions > Email Addresses and set it to Read-Only, otherwise you’ll get an email_not_found error.

Custom OAuth providers

For any provider not in the built-in list, use the Generic OAuth plugin:
auth.ts