home / skills / derklinke / codex-config / ios-supabase-realtime-ios
/skills/ios-supabase-realtime-ios
This skill helps iOS developers implement and optimize Supabase Realtime with Postgres, Broadcast, or Presence, ensuring correct lifecycle and best practices.
npx playbooks add skill derklinke/codex-config --skill ios-supabase-realtime-iosReview the files below or copy the command above to add this skill to your agents.
---
name: supabase-realtime-ios
description: Use when implementing or reviewing Supabase Realtime in iOS/Swift apps (supabase-swift). Covers Postgres Changes, Broadcast, Presence, channel lifecycle, and best practices.
---
# Supabase Realtime (iOS / Swift)
## When to use
- The request mentions Supabase Realtime, Postgres changes, broadcast, presence, or realtime channels on iOS/Swift.
- The task needs Swift SDK patterns, channel lifecycle, or realtime best practices.
## Workflow (concise)
1. Clarify which Realtime mode is needed: Postgres Changes vs Broadcast vs Presence.
2. Use Context7 `/supabase/supabase-swift` to confirm current Swift API shapes (Realtime V2 vs v1).
3. Use Supabase docs for product behavior, limits, replication, and security details.
4. Choose the right mode:
- Postgres Changes for authoritative DB events.
- Broadcast for low-latency, ephemeral client-to-client messages.
- Presence for shared state and online user lists.
5. On iOS, wire lifecycle: subscribe on view appear/foreground, clean up on disappear/background.
## References
- `references/realtime-overview.md` for concepts, tradeoffs, and server-side setup.
- `references/swift-realtime-patterns.md` for Swift/iOS usage patterns.
This skill helps implement and review Supabase Realtime features in iOS/Swift apps using the supabase-swift SDK. It focuses on choosing the correct realtime mode (Postgres Changes, Broadcast, Presence), wiring channel lifecycle to iOS app states, and applying production-safe patterns. The guidance is practical and targeted at engineers building realtime behaviors on Apple platforms.
It inspects your use of Supabase Realtime concepts and maps them to Swift SDK patterns, emphasizing channel subscription, message handling, and cleanup. It checks whether you chose Postgres Changes, Broadcast, or Presence appropriately and recommends API shapes and lifecycle hooks for view controllers and app background/foreground events. It also flags common pitfalls like missing cleanup, excessive subscriptions, or insecure channel usage.
When should I use Broadcast vs Postgres Changes?
Use Postgres Changes when events must reflect durable DB state. Use Broadcast for ephemeral client messages where durability and ordering are not required.
How do I avoid memory leaks with realtime channels on iOS?
Tie subscriptions to view/controller lifecycle: subscribe on appear/foreground and explicitly leave channels and remove listeners on disappear/background. Prefer a centralized connection manager to oversee cleanup.