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.
Swift: Retrieve a new session
This method will refresh the stored session whether the current one is expired or not.
When a concurrent refresh or sign-in already replaced the session with a valid one, it returns that session without a request.
The client runs one refresh at a time. When a refresh fails, a new refresh with the same token in the next 60 seconds throws the same error without a request.
A rejected refresh does not sign out while the access token is still valid. Wait for the .signedOut event instead of treating the error as a sign-out.
To sign in with a refresh token from elsewhere, use importSession(accessToken:refreshToken:).
Examples
Refresh session using the current session
let session = try await supabase.auth.refreshSession()
Refresh the session only when needed
let session = try await supabase.auth.refreshSessionIfNeeded()