Swiftpack.co - supabase-community/supabase-swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by supabase-community.
supabase-community/supabase-swift 0.0.4
A Swift client for Supabase
⭐️ 109
🕓 7 weeks ago
iOS macOS watchOS tvOS macCatalyst
.package(url: "https://github.com/supabase-community/supabase-swift.git", from: "0.0.4")


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


Swift Package Manager:

Add the following lines to your Package.swift file:

let package = Package(
    dependencies: [
        .package(name: "Supabase", url: "https://github.com/supabase/supabase-swift.git", .exact("0.0.2")), // Add the package
    targets: [
            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/supabase-swift.git for the url when Xcode asks.


For all requests made for supabase, you will need to initialize a SupabaseClient object.

let client = SupabaseClient(supabaseUrl: "{ Supabase URL }", supabaseKey: "{ Supabase anonymous Key }")

This client object will be used for all the following examples.


Query todo table for all completed todos.

struct Todo: Codable {
    var id: String = UUID().uuidString
    var label: String
    var isDone: Bool = false
let query = try client.database.from("todos")
    .eq(column: "isDone", value: "true")
query.execute { [weak self] results in
    guard let self = self else { return }

    switch results {
    case let .success(response):
        let todos = try? response.decoded(to: [Todo].self)
    case let .failure(error):

Insert a todo into the database.

let todo = Todo(label: "Example todo!")

let jsonData: Data = try JSONEncoder().encode(todo)
let jsonDict: [String: Any] = try JSONSerialization.jsonObject(with: jsonData, options: .allowFragments))

    .insert(values: jsonDict)
    .execute { results in
        // Handle response

For more query examples visit the Javascript docs to learn more. The API design is a near 1:1 match.

Execute an RPC

do {
    try client.database.rpc(fn: "testFunction", parameters: nil).execute { result in
        // Handle result
} catch {
   print("Error executing the RPC: \(error)")


Realtime docs coming soon


Sign up with email and password

client.auth.signUp(email: "test@mail.com", password: "password") { result in
    switch result {
    case let .success(session, user): print(user)
    case let .failure(error): print(error.localizedDescription)

Login up with email and password

client.auth.signIn(email: "test@mail.com", password: "password") { result in
    switch result {
    case let .success(session): print(session.accessToken, session.user)
    case let .failure(error): print(error.localizedDescription)


Storage docs coming soon


  • 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


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


Stars: 109
Last commit: 2 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics