Supabase SwiftUI Tutorial: Auth, Database & Sign in with Apple
Learn how to integrate Supabase with SwiftUI for authentication (including Sign in with Apple), Postgres database access with Row Level Security, and file storage. This Supabase SwiftUI tutorial covers everything indie iOS developers need.
Why Supabase for SwiftUI?
Supabase is the open-source Firebase alternative that indie iOS developers love. It gives you a Postgres database, auth (with Sign in with Apple support), real-time subscriptions, storage, and Edge Functions — all with a generous free tier. Combined with SwiftUI, it's the fastest way to build a full-stack iOS app.
What You'll Learn in This Supabase SwiftUI Tutorial
- Project setup — Create a Supabase project and configure the Swift client
- Authentication — Email/password + SwiftUI Sign in with Apple tutorial
- Session management — Automatic token refresh and auth state handling
- Database access — CRUD operations with Postgres and RLS policies
- Storage — Upload and retrieve files (avatars, user content)
- Edge Functions — Server-side logic for webhooks and background tasks
Step 1: Setting Up Supabase in SwiftUI
Add the supabase-swift package via SPM, then configure the client with your project URL and anon key. The Swift Kit's Supabase adapter wraps this in a clean singleton with automatic session persistence.
// SupabaseManager.swift
import Supabase
let supabase = SupabaseClient(
supabaseURL: URL(string: "YOUR_PROJECT_URL")!,
supabaseKey: "YOUR_ANON_KEY"
)Step 2: SwiftUI Sign in with Apple Tutorial
Supabase supports Sign in with Apple natively. In SwiftUI, you use Apple's SignInWithAppleButton, pass the identity token to Supabase, and the auth flow is complete. The Swift Kit includes a pre-built Sign in with Apple view that handles the full flow including error states and loading indicators.
Step 3: Database with Row Level Security
Supabase uses Postgres with RLS (Row Level Security) policies to control data access per user. The Swift Kit includes pre-configured RLS policies for common patterns: user profiles, user content, and shared data.
Skip the Tutorial — Use The Swift Kit
Don't want to wire all this manually? The Swift Kit includes a complete Supabase SwiftUI integration out of the box — auth, database, storage, and Edge Functions. Just paste your Supabase project URL and anon key.