Chat sync is optional and off by default — chat history stays local-only in SwiftData until you enable it. The complete setup guide lives at
docs/integrations/ChatSync.md in your project.What Is Chat Sync?
Offline-First
Writes go to the local database first
Background Sync
Syncs to cloud in background
Cross-Device
Access from all devices
Optional
Enable only when needed
Quick Overview
Enable the Feature Flag
Flip the
chatSyncEnabled flag in SwiftAIBoilerplatePro/Composition/FeatureFlags.swift. By default it is false in DEBUG and reads the CHAT_SYNC_ENABLED environment variable in Release:Uncomment the Supabase Implementations
Both Supabase repositories ship commented out until the Supabase dependency is added. Uncomment them in the Storage package:
Packages/Storage/Sources/Storage/Repositories/SupabaseConversationRepository.swiftPackages/Storage/Sources/Storage/Repositories/SupabaseMessageRepository.swift
Wire Up the Hybrid Repositories in CompositionRoot
In
SwiftAIBoilerplatePro/Composition/CompositionRoot.swift, the chat-sync branch currently falls back to the local repositories (a // TODO: wire Supabase remote repos once a signed-in user id is available marks the spot). Replace that with the hybrid repositories once you have a signed-in user id:How It Works
HybridConversationRepository and HybridMessageRepository write to the local SwiftData store first and sync to the remote Supabase repository in a background Task. If the remote write fails, the local save still succeeds, so the app keeps working offline.
Prerequisites
- Supabase project configured (see Supabase Setup)
- Supabase dependency added to the Storage package
- User authenticated
What You Get
- Conversations and messages sync across devices
- Offline-first behavior preserved (local writes never block on the network)
- Background sync that degrades gracefully when the remote is unavailable
Complete Guide
The fulldocs/integrations/ChatSync.md guide covers the database schema, Row Level Security policies, repository implementations, the hybrid sync strategy, conflict resolution, testing, and troubleshooting.
View Complete Setup Guide
Full chat sync guide with architecture diagrams, in your project repo
Related Guides
Storage Module
Repository architecture
Profile Photos
Another optional sync feature
Supabase Setup
Required backend
Building Your App
Customize features
Need Help?
- Troubleshooting section in the full
docs/integrations/ChatSync.mdguide - Create an issue
- Check the Supabase Dashboard logs
