Swift: Overview

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

Handling deep links

UIKit app lifecycle

public func application(
  _ application: UIApplication,
  didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool \{
  if let url = launchOptions?[.url] as? URL \{
    supabase.auth.handle(url)
  \}

  return true
\}

func application(
  _ app: UIApplication,
  open url: URL,
  options: [UIApplication.OpenURLOptionsKey: Any]
) -> Bool \{
  supabase.auth.handle(url)
  return true
\}

#### UIKit app lifecycle with scenes

In your `SceneDelegate.swift`:

```swift
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) \{
  guard let url = URLContexts.first?.url else \{ return \}
  supabase.auth.handle(url)
\}

SwiftUI app lifecycle

In your AppDelegate.swift:

SomeView()
  .onOpenURL \{ url in
    supabase.auth.handle(url)
  \}

Examples

Create auth client

let supabase = SupabaseClient(supabaseURL: URL(string: "https://xyzcompany.supabase.co")!, supabaseKey: "public-anon-key")
let auth = supabase.auth

Create auth client with custom storage

let supabase = SupabaseClient(
  supabaseURL: URL(string: "https://xyzcompany.supabase.co")!, 
  supabaseKey: "public-anon-key",
  options: .init(
    auth: .init(
      MyCustomLocalStorage()
    )
  )
)
let auth = supabase.auth