Aura Auth
API ReferenceServerapi

isProviderConnected

Complete API reference for the api.isProviderConnected method, verifying whether the current session has an active connection with a specific OAuth provider.

The api.isProviderConnected method checks whether the current session has an active connection with a specific OAuth provider. This method runs on the server, so it requires you to pass the request or headers object from your server-side context.

is-provider-connected.ts
import { api } from "@/lib/auth"

const output = await api.isProviderConnected("github", {
  request: getRequest(),
})

This method only checks connection status — it doesn't return any token data. If you need the access token itself, use api.getAccessToken instead.

Reference

Parameters

ParameterTypeRequiredDescription
providerIdstringYesThe id of the OAuth provider to check the connection for.
optionsProviderConnectedAPIOptionsYesAn object containing request context.

ProviderConnectedAPIOptions

OptionTypeDefaultDescription
requestRequestundefinedThe request object from the server-side context.
headersHeadersundefinedThe headers object from the server-side context.
skipCSRFCheckbooleanfalseWhether to skip CSRF token verification for this request.

At least one of request or headers is required to construct the incoming URL and validate redirect URLs.

Returns

Return TypeDescription
Promise<ProviderConnectedAPIReturn>Resolves to an object containing success and connected — see Behavior.

Behavior

  • On success, connected resolves to true or false depending on whether the specified provider is currently connected to the session — it does not throw for the "not connected" case, since that's an expected outcome, not an error.
  • CSRF protection is verified by default. Set skipCSRFCheck: true only if you're enforcing CSRF protection at a different layer (e.g. a framework-level middleware) — disabling it here without an equivalent safeguard reintroduces the vulnerability it protects against.
  • If the check itself fails (e.g. no valid session), connected resolves to null and success is false — distinct from connected: false, which means the check succeeded and simply found no connection.

Usage

Check a provider's connection status

is-provider-connected.ts
import { api } from "@/lib/auth"

const { success, connected } = await api.isProviderConnected("github", {
  request: getRequest(),
})

Prompting the user to connect a provider

connect-prompt.ts
import { api } from "@/lib/auth"

const { success, connected } = await api.isProviderConnected("github", {
  request: getRequest(),
})

if (success && !connected) {
  redirect("/settings/connections/github")
}

On this page