Let a signed-in user connect Google, GitHub, or another social identity.
Account settings
Better Auth · Module
authClient.linkSocial links an additional social or OAuth provider to the signed-in user's existing Better Auth account. It can redirect through OAuth, request extra scopes, or use provider ID tokens directly.
Call this client method while the user is signed in to begin an OAuth flow for an additional social provider. After the provider confirms the connection, Better Auth associates that provider with the existing user account and redirects to the supplied callback URL.
await authClient.linkSocial({ provider, callbackURL?, scopes?, idToken? });| Name | Type | Description |
|---|---|---|
provider | string | Social provider identifier to link, for example google. |
callbackURL | string, optional | URL to visit after linking completes. |
scopes | string[], optional | Additional provider scopes to request. |
idToken | object, optional | Provider token payload for direct linking; the ID token is required, while nonce, access, and refresh tokens may be optional depending on the provider. |
The page documents the linking operation and redirect flow but does not state a standalone return type.
authClient.linkSocial.import { authClient } from "@/lib/auth-client";
await authClient.linkSocial({
provider: "google",
callbackURL: "/settings",
});Starts the Google OAuth flow and returns the user to the settings page after linking.
Account settings
Permission expansion
Native provider sign-in
linkSocial do?It links an OAuth or social-provider identity to the currently authenticated user's account. The client method is authClient.linkSocial, and it accepts a provider identifier plus optional redirect and scope settings.
Follow-up: How would you link an account from server code? Use auth.api.linkSocialAccount with the provider in the request body and pass headers containing the user's session token.
linkSocial?The provider value identifies the social provider to connect, while callbackURL controls where the browser goes after linking. scopes can request additional provider permissions.
Follow-up: What should be checked when adding scopes? Confirm that the provider supports the requested scopes and that the resulting consent flow is appropriate for the application.
Account linking is enabled by default. A social account can be connected when the provider confirms the email as verified, allowing multiple authentication methods to belong to one Better Auth account.
Follow-up: What is an alternative to redirect-based linking? The documentation also describes linking with provider ID tokens, but the token must be valid and the provider must support ID-token verification.
signIn.socialauth.api.linkSocialAccountsocialProvidersGeneric OAuth PluginAccount linking