Social account login
Offer GitHub, Google, Apple, or another configured OAuth provider as a login option.
Better Auth · Module
signIn.social starts client-side OAuth sign-in for a configured social provider. Pass the provider ID and optionally a redirect URL or extra authorization parameters.
The client method receives a social provider identifier and can include a post-authentication callback URL. Better Auth then begins the provider’s OAuth flow; the provider must already be configured in the auth instance.
authClient.signIn.social({ provider, callbackURL?, additionalParams? })| Name | Type | Description |
|---|---|---|
provider | string | The configured social provider identifier, for example github, google, or apple. |
callbackURL | string | URL to redirect to after authentication; the documented default is /. |
additionalParams | Record<string, string> | Additional query parameters sent to the provider authorization endpoint. |
A promise for the sign-in operation; the resulting response contains the authentication result or error.
signIn.social for client-side social authentication.provider to the configured provider identifier, such as github, google, or apple.callbackURL to control the destination after the provider completes authentication.additionalParams when the provider needs extra authorization query parameters.import { createAuthClient } from "better-auth/client";
const authClient = createAuthClient();
await authClient.signIn.social({
provider: "github",
callbackURL: "/dashboard",
});Starts social authentication with GitHub and requests a redirect to the dashboard after authentication.
Offer GitHub, Google, Apple, or another configured OAuth provider as a login option.
Send users to a dashboard or onboarding route after successful authentication.
Pass provider-specific authorization hints or consent parameters.
Call authClient.signIn.social with an object containing the provider ID, such as github or google. The provider must be configured under the auth instance’s socialProviders option.
Follow-up: How would server-side code initiate the same flow? Use auth.api.signInSocial and place the provider in its request body.
Pass callbackURL in the options object to specify the destination after successful provider authentication. If omitted, the documented default is /.
Follow-up: How can provider-specific authorization parameters be forwarded? Add them through additionalParams on the social sign-in call.
The provider value identifies which configured OAuth provider should handle authentication. Examples in the documentation include GitHub, Google, and Apple.
Follow-up: What must be configured before this call can work? Supply the provider credentials and configuration in socialProviders on the auth setup.
socialProvidersauthClientauth.api.signInSociallinkSocialcallbackURLadditionalParams