For AI agents: the documentation index is at llms.txt. Guide pages have a markdown version at the same path with .md appended, before any query string or fragment.

JavaScript: exchangeCodeForSession

Log in an existing user by exchanging an Auth Code issued during the PKCE flow.

Parameters

Examples

Exchange Auth Code

supabase.auth.exchangeCodeForSession('34e770dd-9ff9-416c-87fa-43b31d7ef225')

Exchange Auth Code for a specific flow (e.g. in a server-side callback handler)

const flowId = requestUrl.searchParams.get('sb_flow_id')
supabase.auth.exchangeCodeForSession(code, flowId ? { flowId } : undefined)