A Swift SDK for Supabase. Query your Supabase database, subscribe to realtime events, upload and download files, browse Swift examples, invoke postgres functions via rpc, invoke supabase edge functions, query pgvector.
See the code| Library | Description |
|---|---|
| Supabase | Full client — includes all libraries below |
| Auth | User authentication and session management |
| PostgREST | Query your Postgres database via REST |
| Realtime | Subscribe to database changes over WebSocket |
| Storage | Manage files and objects |
| Functions | Invoke Supabase Edge Functions |
[!IMPORTANT] Check the Support Policy to learn when dropping Xcode, Swift, and platform versions will not be considered a breaking change.
Add supabase-swift as a Swift Package Manager dependency:
let package = Package(
...
dependencies: [
.package(
url: "https://github.com/supabase/supabase-swift.git",
from: "2.0.0"
),
],
targets: [
.target(
name: "YourTargetName",
dependencies: [
.product(name: "Supabase", package: "supabase-swift")
]
)
]
)
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.
You can also add individual libraries (Auth, Realtime, Storage, PostgREST, Functions) instead of the full Supabase product.
let client = SupabaseClient(
supabaseURL: URL(string: "https://xyzcompany.supabase.co")!,
supabaseKey: "your-publishable-key"
)
let client = SupabaseClient(
supabaseURL: URL(string: "https://xyzcompany.supabase.co")!,
supabaseKey: "your-publishable-key",
options: SupabaseClientOptions(
db: .init(
schema: "public"
),
auth: .init(
storage: MyCustomLocalStorage(),
flowType: .pkce
),
global: .init(
headers: ["x-my-custom-header": "my-app-name"],
http: .init(transport: URLSessionTransport(session: URLSession.myCustomSession))
)
)
)
struct Answer: Decodable { let text: String }
// JSON in, typed JSON out
let answer: Answer = try await client.functions.invoke("ask", body: .json(["prompt": "hi"]))
// Raw response: status, headers, bytes
let response = try await client.functions.invoke("report", options: .init(method: .get))
print(response.status, response.body.count)
let response = try await client.functions.stream("chat", body: .json(["prompt": "hi"]))
for try await chunk in response.body {
// chunk boundaries follow the network; frame server-sent events yourself
}
supabase gen types --lang swift writes @Table structs for your schema. It runs the
supabase-typegen executable, which ships with each supabase-swift release. The CLI reads your
supabase-swift version from Package.resolved and downloads the matching build itself. You need
to install it by hand only when the CLI cannot do that, for example without network access. It then
uses the supabase-typegen it finds on your PATH. Install the build that matches the
supabase-swift version your project uses:
VERSION=2.55.1 # your supabase-swift version
ASSET=supabase-typegen-macos-universal.tar.gz # or supabase-typegen-linux-x86_64.tar.gz
mkdir -p ~/.local/bin
curl -fsSL "https://github.com/supabase/supabase-swift/releases/download/v$VERSION/$ASSET" | tar -xz -C ~/.local/bin
supabase-typegen --version
Put ~/.local/bin on your PATH if it is not there yet. Then generate the file:
supabase gen types --lang swift --local > Sources/App/Database.swift
On macOS, a binary you download with a browser is quarantined, and Gatekeeper blocks it. curl
does not set the quarantine flag. To clear it from a browser download, run
xattr -d com.apple.quarantine ~/.local/bin/supabase-typegen.
Additional examples are available in the Examples directory.
We only support Xcode versions that are currently eligible for submitting apps to the App Store. Once a specific version of Xcode is no longer supported, its removal from Supabase won't be treated as a breaking change and will occur in a minor release.
The minimum supported Swift version corresponds to the minor version released with the oldest-supported Xcode version. When a Swift version reaches its end of support, it will be dropped in a minor release, and this won't be considered a breaking change.
We maintain support for the four latest major versions of each platform, including the current version.
When a platform version is no longer supported, Supabase will drop it in a minor release, and this won't count as a breaking change. For instance, iOS 14 will no longer be supported after the release of iOS 18, allowing its removal in a minor update.
For macOS, the named yearly releases are treated as major versions for this policy, regardless of their version numbers.
[!IMPORTANT] Android, Linux and Windows work but aren't officially supported, and may stop working in future versions of the library.
We welcome contributions! Please see the steps below.
git checkout -b feature/my-feature)../scripts/format.sh to format Swift code.PLATFORM=IOS XCODEBUILD_ARGUMENT=test ./scripts/xcodebuild.sh to verify tests pass.feat(auth): add PKCE support).main.This project is licensed under the MIT License — see the LICENSE file for details.
Website • Documentation • Community • Twitter
A Swift SDK for Supabase. Query your Supabase database, subscribe to realtime events, upload and download files, browse Swift examples, invoke postgres functions via rpc, invoke supabase edge functions, query pgvector.
See the code| Library | Description |
|---|---|
| Supabase | Full client — includes all libraries below |
| Auth | User authentication and session management |
| PostgREST | Query your Postgres database via REST |
| Realtime | Subscribe to database changes over WebSocket |
| Storage | Manage files and objects |
| Functions | Invoke Supabase Edge Functions |
[!IMPORTANT] Check the Support Policy to learn when dropping Xcode, Swift, and platform versions will not be considered a breaking change.
Add supabase-swift as a Swift Package Manager dependency:
let package = Package(
...
dependencies: [
.package(
url: "https://github.com/supabase/supabase-swift.git",
from: "2.0.0"
),
],
targets: [
.target(
name: "YourTargetName",
dependencies: [
.product(name: "Supabase", package: "supabase-swift")
]
)
]
)
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.
You can also add individual libraries (Auth, Realtime, Storage, PostgREST, Functions) instead of the full Supabase product.
let client = SupabaseClient(
supabaseURL: URL(string: "https://xyzcompany.supabase.co")!,
supabaseKey: "your-publishable-key"
)
let client = SupabaseClient(
supabaseURL: URL(string: "https://xyzcompany.supabase.co")!,
supabaseKey: "your-publishable-key",
options: SupabaseClientOptions(
db: .init(
schema: "public"
),
auth: .init(
storage: MyCustomLocalStorage(),
flowType: .pkce
),
global: .init(
headers: ["x-my-custom-header": "my-app-name"],
http: .init(transport: URLSessionTransport(session: URLSession.myCustomSession))
)
)
)
struct Answer: Decodable { let text: String }
// JSON in, typed JSON out
let answer: Answer = try await client.functions.invoke("ask", body: .json(["prompt": "hi"]))
// Raw response: status, headers, bytes
let response = try await client.functions.invoke("report", options: .init(method: .get))
print(response.status, response.body.count)
let response = try await client.functions.stream("chat", body: .json(["prompt": "hi"]))
for try await chunk in response.body {
// chunk boundaries follow the network; frame server-sent events yourself
}
supabase gen types --lang swift writes @Table structs for your schema. It runs the
supabase-typegen executable, which ships with each supabase-swift release. The CLI reads your
supabase-swift version from Package.resolved and downloads the matching build itself. You need
to install it by hand only when the CLI cannot do that, for example without network access. It then
uses the supabase-typegen it finds on your PATH. Install the build that matches the
supabase-swift version your project uses:
VERSION=2.55.1 # your supabase-swift version
ASSET=supabase-typegen-macos-universal.tar.gz # or supabase-typegen-linux-x86_64.tar.gz
mkdir -p ~/.local/bin
curl -fsSL "https://github.com/supabase/supabase-swift/releases/download/v$VERSION/$ASSET" | tar -xz -C ~/.local/bin
supabase-typegen --version
Put ~/.local/bin on your PATH if it is not there yet. Then generate the file:
supabase gen types --lang swift --local > Sources/App/Database.swift
On macOS, a binary you download with a browser is quarantined, and Gatekeeper blocks it. curl
does not set the quarantine flag. To clear it from a browser download, run
xattr -d com.apple.quarantine ~/.local/bin/supabase-typegen.
Additional examples are available in the Examples directory.
We only support Xcode versions that are currently eligible for submitting apps to the App Store. Once a specific version of Xcode is no longer supported, its removal from Supabase won't be treated as a breaking change and will occur in a minor release.
The minimum supported Swift version corresponds to the minor version released with the oldest-supported Xcode version. When a Swift version reaches its end of support, it will be dropped in a minor release, and this won't be considered a breaking change.
We maintain support for the four latest major versions of each platform, including the current version.
When a platform version is no longer supported, Supabase will drop it in a minor release, and this won't count as a breaking change. For instance, iOS 14 will no longer be supported after the release of iOS 18, allowing its removal in a minor update.
For macOS, the named yearly releases are treated as major versions for this policy, regardless of their version numbers.
[!IMPORTANT] Android, Linux and Windows work but aren't officially supported, and may stop working in future versions of the library.
We welcome contributions! Please see the steps below.
git checkout -b feature/my-feature)../scripts/format.sh to format Swift code.PLATFORM=IOS XCODEBUILD_ARGUMENT=test ./scripts/xcodebuild.sh to verify tests pass.feat(auth): add PKCE support).main.This project is licensed under the MIT License — see the LICENSE file for details.
Website • Documentation • Community • Twitter