API ReferencecreateAuthClient
disconnectProvider
Disconnect an OAuth provider from the current session, from the client.
The disconnectProvider client method disconnects an OAuth provider from the current session, without revoking its access token, from a client-side or browser context.
import { authClient } from "@/lib/auth-client"
const success = await authClient.disconnectProvider("github")This is a softer alternative to revokeToken: it disconnects the provider from the session without revoking the access token
itself. See revokeToken for the stronger alternative.
Reference
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| providerId | string | Yes | The id of the OAuth provider to disconnect. |
Returns
| Return Type | Description |
|---|---|
Promise<boolean> | Resolves to true if the provider was successfully disconnected, false otherwise. |
Behavior
- Cookies are read automatically from the browser context — you don't need to handle them or CSRF tokens manually.
- The access token itself remains valid until it naturally expires or is separately revoked with
revokeToken. - If disconnection fails (the provider isn't connected to the current session), the method resolves to
false— this does not throw an error, as "not connected" is an expected outcome.
Usage
Disconnect a provider
import { authClient } from "@/lib/auth-client"
const success = await authClient.disconnectProvider("github")Handling failure
import { authClient } from "@/lib/auth-client"
const success = await authClient.disconnectProvider("github")
if (!success) {
window.location.assign("/settings/connections")
}