Skip to content

jmshgs/supabase-swift

 
 

Repository files navigation

supabase-swift

Supabase client for swift. Mirrors the design of supabase-js.

Warning

This library is a work in progress, you can choose to use the last available version 0.3.0, or use the main branch that contains the next 1.0 release. 1.0 will have several breaking changes, so I don't recommend you start a project using 0.3, just use the main branch from now, as the API is pretty much stable at this stage.

Usage

Install the library using the Swift Package Manager.

let package = Package(
    ...
    dependencies: [
        ...
        .package(name: "Supabase", url: "https://github.com/supabase-community/supabase-swift.git", branch: "main"), // Add the package
    ],
    targets: [
        .target(
            name: "YourTargetName",
            dependencies: ["Supabase"] // Add as a dependency
        )
    ]
)

If you're using Xcode, use this guide to add supabase-swift to your project. Use https://github.com/supabase-community/supabase-swift.git for the url when Xcode asks.

If you don't want the full Supabase environment, you can also add individual packages, such as Functions, GoTrue, Realtime, Storage, or PostgREST.

Then you're able to import the package and establish the connection with the database.

/// Create a single supabase client for interacting with your database
let client = SupabaseClient(supabaseURL: URL(string: "https://xyzcompany.supabase.co")!, supabaseKey: "public-anon-key")

Initialize 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
        )
    )
)

Contributing

  • Fork the repo on GitHub
  • Clone the project to your own machine
  • Commit changes to your own branch
  • Push your work back up to your fork
  • Submit a Pull request so that we can review your changes and merge

Sponsors

We are building the features of Firebase using enterprise-grade, open source products. We support existing communities wherever possible, and if the products don’t exist we build them and open source them ourselves. Thanks to these sponsors who are making the OSS ecosystem better for everyone.

New Sponsor

Releases

No releases published

Packages

No packages published

Languages

  • Swift 99.6%
  • Makefile 0.4%