Swift: Initializing

You can initialize Supabase with the SupabaseClient by passing your Project URL and Project Key. You can find these under your Project SettingsAPI Settings The Supabase client is your entrypoint to the rest of the Supabase functionality and is the easiest way to interact with everything we offer within the Supabase ecosystem.

Examples

Initialize Client

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

Initialize Client with custom options

let client = SupabaseClient(
  supabaseURL: URL(string: "https://xyzcompany.supabase.co")!, 
  supabaseKey: "public-anon-key",
  options: SupabaseClientOptions(
    db: .init(
      schema: "public"
    ),
    auth: .init(
      storage: MyCustomLocalStorage(),
      flowType: .pkce
    ),
    global: .init(
      headers: ["x-my-custom-header": "my-app-name"],
      session: URLSession.myCustomSession
    )
  )
)

With custom schemas

let supabase = SupabaseClient(
  supabaseURL: URL(string: "https://xyzcompany.supabase.co")!,
  supabaseKey: "public-anon-key",
  options: SupabaseClientOptions(
    db: .init(
      // Provide a custom schema. Defaults to "public".
      schema: "other_schema"
    )
  )
)