How to integrate Supabase authentication in Swift.

Fredric Cliver
4 min readSep 30, 2023

Install Supabase through the Swift package manager.

repo is here:

Swift package manager, Supabase-swift

Using SPM, install the supabase-swift package.

Code implementation

// AuthManager.swift
// Created by Fredric Cliver

import AuthenticationServices
import Foundation
@_spi(Experimental) import GoTrue
import Supabase

let MySupabaseUrlString: String = "https://{project-id}"
let MySupabaseUrl: URL = URL(string: "https://{project-id}")!
let MySupabaseKey: String =
"{supabase secret key}"

class AuthManager {
static let shared = AuthManager()
private init() {}

let supabaseClient = SupabaseClient(supabaseURL: MySupabaseUrl, supabaseKey: MySupabaseKey)

// referenced from
func loginWithAppleViaSupabase(
_ credential: ASAuthorizationAppleIDCredential, completion: @escaping (User?) -> Void
) {

let idToken = credential.identityToken
.flatMap({ String(data: $0, encoding: .utf8) })
else {…



Fredric Cliver

Majored in Physics, self-taught and worked in the IT industry as a Dev/Design/Planning for 11 years. And I had run my Startup for 3 years. I fancy a ☔️ 🇬🇧