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: Overview

The auth methods can be accessed via the supabase.auth namespace.

AuthClient is a Sendable class, not an actor. It reads the stored session asynchronously after the client is created. Until then, status is .loading and currentSession is nil. Call await supabase.auth.initialization() before you read currentSession at launch.

Handling deep links

Flows that leave the app, such as magic links, email confirmations, password resets, and OAuth links that you open yourself, return with a URL. Pass that URL to handleRedirect(_:). It returns nil for a URL that is not an auth redirect. A URL is an auth redirect only when it opens the configured redirectTo or the redirectTo of a pending flow, so set redirectTo on the client configuration.

signInWithOAuth, signInWithSSO, and linkIdentity show the provider page and finish the flow themselves. You do not need to handle their URLs.

UIKit app lifecycle

func application(
  _ app: UIApplication,
  open url: URL,
  options: [UIApplication.OpenURLOptionsKey: Any]
) -> Bool {
  Task {
    try await supabase.handleRedirect(url)
  }
  return true
}

UIKit app lifecycle with scenes

In your SceneDelegate.swift:

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
  guard let url = URLContexts.first?.url else { return }
  Task {
    try await supabase.handleRedirect(url)
  }
}

SwiftUI app lifecycle

On the root view of your scene:

SomeView()
  .onOpenURL { url in
    Task {
      try await supabase.handleRedirect(url)
    }
  }

When the app also opens other deep links, check the URL first with await supabase.auth.isAuthRedirect(url).

Examples

Create auth client

let supabase = try SupabaseClient(
  supabaseURL: URL(string: "https://xyzcompany.supabase.co")!,
  supabaseKey: "your-publishable-key",
  configuration: .init(
    auth: .init(redirectTo: URL(string: "my-app-scheme://callback")!)
  )
)
let auth = supabase.auth

Create auth client with custom storage

// An in-memory store. Replace the dictionary with your own storage.
actor MyCustomStorage: AuthStorage {
  private var values: [String: Data] = [:]

  func load(key: String) async throws -> Data? { values[key] }
  func save(_ data: Data, key: String) async throws { values[key] = data }
  func remove(key: String) async throws { values[key] = nil }
}

let supabase = try SupabaseClient(
  supabaseURL: URL(string: "https://xyzcompany.supabase.co")!,
  supabaseKey: "your-publishable-key",
  configuration: .init(
    auth: .init(storage: MyCustomStorage())
  )
)
let auth = supabase.auth