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: Upgrade guide

Upgrade your app from supabase-swift v2 to v3 and fix the compile errors that the upgrade causes. v3 renames many public types and methods, so most errors come from a rename. This page covers the changes that affect every app.

For the full list, including the changes that still compile but behave differently, see the supabase-swift repository on GitHub. It has the v3 migration guide and the module guides for Auth, PostgREST, Storage, Functions, and Realtime.

Upgrade the client library

  1. Install Xcode 26.0 or later. v3 needs Swift 6.2 or later, which Xcode 26.0 includes.
  2. Update the supabase-swift package requirement to 3.0.0-alpha.2.
  3. If your app pins swift-crypto below 4.0.0, raise the pin to 4.0.0 or later. v3 needs swift-crypto 4.0.0 or later.
.package(url: "https://github.com/supabase/supabase-swift", from: "3.0.0-alpha.2")

Create the client with a configuration

v3 renames SupabaseClientOptions to SupabaseClient.Configuration, and the initializer label is configuration:. The nested types drop their Options suffix, and db is renamed to database.

In v3, every client initializer throws when the URL has no scheme or no host. Add try.

Headers are HTTPFields. Write each key as an HTTPField.Name.

let client = SupabaseClient(
  supabaseURL: url,
  supabaseKey: key,
  options: SupabaseClientOptions(
    db: .init(schema: "app"),
    global: .init(headers: ["x-app": "demo"])
  )
)
var configuration = SupabaseClient.Configuration()
configuration.database.schema = "app"
configuration.global.headers = [HTTPField.Name("x-app")!: "demo"]

let client = try SupabaseClient(
  supabaseURL: url,
  supabaseKey: key,
  configuration: configuration
)

Use swift-log for logging

In v3, every logger: parameter takes a Logging.Logger from the swift-log package on GitHub. v3 removes SupabaseLogger and OSLogSupabaseLogger. Add swift-log to your package and import Logging where you build the logger.

When you pass no logger, debug builds log warnings and errors to stderr. Release builds stay silent.

import Logging
import Supabase

var logger = Logger(label: "myapp")
logger.logLevel = .debug

let client = try SupabaseClient(
  supabaseURL: url,
  supabaseKey: key,
  configuration: .init(global: .init(logger: logger))
)

Replace fetch closures and URLSession options

v3 replaces the fetch closures and the URLSession options with a transport and middleware. Every client sends requests through one ClientTransport behind an ordered list of ClientMiddleware. Both go in one HTTPClientConfiguration, passed as http:. URLSessionTransport(session:) wraps the URLSession that you used in v2.

In v3, the SDK sets the request timeout itself: 60 seconds, or 150 seconds for Functions. To change it, set HTTPClientConfiguration(timeout:).

let client = SupabaseClient(
  supabaseURL: url,
  supabaseKey: key,
  options: .init(global: .init(session: mySession))
)
let client = try SupabaseClient(
  supabaseURL: url,
  supabaseKey: key,
  configuration: .init(
    global: .init(http: .init(transport: URLSessionTransport(session: mySession)))
  )
)

Catch errors by module

v3 removes HTTPError. Each module throws its own error type: AuthError, PostgrestError, StorageError, FunctionsError, or RealtimeError. Each one conforms to SupabaseError and has a kind, a code, the response, and an underlyingError.

The SDK wraps a URLError or DecodingError in the module error and keeps the original in underlyingError. In v3, a canceled task throws CancellationError in every module.

Errors that your own transport or middleware throws reach you unchanged. Keep the handlers for those errors.

do {
  try await supabase.from("todos").insert(todo).execute()
} catch PostgrestError.Code.uniqueViolation {
  showDuplicate()
} catch PostgrestError.Kind.transport {
  showOfflineBanner()
} catch let error as any SupabaseError {
  if let response = error.response {
    print(response.status.code, String(decoding: response.body, as: UTF8.self))
  }
}

Other renames and removals

v3 also renames the following methods, types, and arguments:

v3 removes the following: