Supabase Realtime - AI-Optimized Technical Reference
Configuration That Actually Works in Production
Database Changes (Postgres Changes)
- Purpose: Stream INSERT, UPDATE, DELETE events from database
- Latency: 100-500ms (WAL replication dependent)
- Reliability: Most reliable but slowest option
- Setup Requirements:
ALTER PUBLICATION supabase_realtime ADD TABLE messages;
- Production Configuration:
const channel = supabase.channel('messages-changes', { config: { heartbeat_timeout: 60000, // Override 30s default reconnect_after_timeout: 5000 } })
Broadcast Messages
- Purpose: Ephemeral real-time messaging between clients
- Latency: <50ms (ideal), 500ms+ during congestion
- Message Limit: 256KB per message
- Delivery: Best-effort (no guarantees)
- Critical Implementation:
// Add timestamp handling for message ordering payload: { data: content, timestamp: Date.now(), sequence: messageId++ }
Presence Tracking
- Purpose: Track user state using CRDTs
- Latency: <50ms
- State Limit: 64KB per presence
- Consistency: Eventually consistent (ghost users accumulate)
Critical Failure Modes
Connection Pool Death Spiral
- Symptom: WebSocket connections timeout during traffic spikes
- Impact: Complete service unavailability
- Resolution: Restart entire service stack
- Prevention: Implement connection limits and backpressure
WAL Replication Lag Hell
- Trigger: Database under heavy write load
- Impact: "Real-time" becomes "eventual-time"
- Performance Threshold: Replication lag >1000ms makes system unusable
- Mitigation: Batch operations, monitor replication slot lag
Message Ordering Chaos
- Cause: Network congestion, no built-in sequencing
- Impact: Collaborative features break (cursors jump randomly)
- Required Solution: Client-side timestamp handling and message sequencing
- Implementation Cost: Additional 20-30% development time
Phantom Presence Problem
- Cause: Force-quit browsers, WiFi disconnections
- Impact: Ghost users accumulate indefinitely
- Consequence: User lists become meaningless over time
- Solution: Custom heartbeat system (not built-in)
Regional Routing Madness
- Expected: 50ms Singapore-US latency
- Reality: 500ms when AWS routing breaks
- Debugging Capability: Zero (black box routing)
- Business Impact: User experience degrades unpredictably
Resource Requirements
Time Investment
- Basic Implementation: 2-3 days
- Production-Ready: 2-3 weeks (debugging edge cases)
- Message Ordering System: Additional 1 week
- Ghost User Cleanup: Additional 3-5 days
Expertise Requirements
- WebSocket Connection Management: Advanced
- Distributed Systems Debugging: Expert level
- PostgreSQL Replication: Intermediate
- Client-Side State Management: Advanced
Billing Traps
- Rate: $2.50 per million messages
- Cursor Movement Reality: 100+ messages/second per user
- Example Cost: 20 users, whiteboard app = $120/week for cursors alone
- Hidden Costs: Heartbeats, reconnection attempts, presence updates all count
- Mitigation: Aggressive rate limiting required
Decision Criteria
When Supabase Realtime Works
- Chat applications: Good for text messages (handle out-of-order delivery)
- Live dashboards: Acceptable for non-critical data updates
- Notifications: Reliable when backed by database storage
- User limit: <100 concurrent users per channel
When to Choose Alternatives
- Financial applications: Never (no delivery guarantees)
- Collaborative editing: Too many message ordering issues
- High-frequency updates: Billing becomes prohibitive
- >1000 concurrent users: Performance degrades significantly
Breaking Points
- Database: WAL replication fails at >500 writes/second
- UI Performance: Breaks at 1000+ UI spans (debugging impossible)
- Message Volume: >10 million messages/month = $25+ just in Realtime costs
- Connection Count: 16,384 WebSocket limit per node
Production Warnings
What Documentation Doesn't Tell You
- Default timeouts will fail: 30s connection timeout appears broken to users
- RLS changes break silently: Recent versions enforce authorization differently
- WAL replication stops randomly: Postgres 15+ issue during high throughput
- Mobile browsers kill connections: Aggressive background tab management
Required Defensive Code Patterns
// Essential error handling
channel
.on('error', (error) => {
// Connection died, implement resurrection logic
handleRealtimeFailure(error)
})
.on('disconnect', (reason) => {
// Mobile browsers, WiFi, corporate firewalls
scheduleReconnection(reason)
})
// Message ordering for broadcasts
const messageQueue = new Map()
function processMessage(payload) {
if (payload.timestamp < lastProcessed[payload.user_id]) {
return // Ignore out-of-order message
}
// Process message
}
// Rate limiting to prevent billing explosion
const rateLimiter = new RateLimiter({
tokensPerInterval: 10,
interval: 1000
})
Migration Pain Points
- No migration guides: Version changes break existing code silently
- Authorization changes: August 2024 update requires code changes
- Client library incompatibilities: Each platform has unique breaking changes
- Database requirements: Managed DB providers often restrict logical replication
Performance Thresholds
Metric | Acceptable | Degraded | Broken |
---|---|---|---|
Connection Latency | <100ms | 100-500ms | >500ms |
WAL Replication Lag | <500ms | 500ms-2s | >2s |
Message Delivery | <50ms | 50-200ms | >200ms |
Concurrent Users | <100 | 100-500 | >500 |
Messages/Hour | <100K | 100K-1M | >1M |
Community and Support Quality
- Discord Community: Responsive for urgent issues (3AM debugging)
- GitHub Issues: Active tracking of real production bugs
- Documentation: Marketing-heavy, light on production gotchas
- Enterprise Support: Available but expensive
- Community Libraries: Python/Swift clients are community-maintained (variable quality)
This system works great in demos but requires significant defensive programming for production use. Budget 3x normal development time for proper error handling and edge case management.
Useful Links for Further Investigation
Essential Supabase Realtime Resources
Link | Description |
---|---|
Supabase Realtime Overview | Decent starting point, but light on production gotchas |
Realtime Architecture Guide | Actually useful for understanding why shit breaks |
Postgres Changes Documentation | Skip to the code examples, ignore the marketing |
Broadcast Features | Doesn't mention the billing traps |
Presence Tracking | Won't tell you about ghost user problems |
Supabase Realtime Server | Elixir source code, check the issues for what actually breaks |
JavaScript Client Library | Most battle-tested client, read the issue tracker before production |
Dart/Flutter Client | Works fine on mobile, fewer edge cases than web |
Python Client Documentation | Community-maintained, your mileage may vary |
Multiplayer.dev | Works great in demo, will cost you $200/month in production |
Realtime Chat Component | Decent starting point, doesn't handle out-of-order messages |
Avatar Stack with Presence | Shows online users, but ghost users will accumulate |
Collaborative Cursor Demo | Missing rate limiting, your bill will explode |
Realtime Pricing Calculator | Doesn't factor in cursor movements or failed reconnects |
Authorization Setup | RLS actually works here, surprisingly |
Performance Benchmarks | Best-case numbers, not production reality |
Error Code Reference | Actually useful for debugging at 3AM |
Broadcast from Database | April 2025 feature, actually works as advertised |
Authorization for Broadcast and Presence | August 2024 security update that breaks old code |
Realtime: Multiplayer Edition | Marketing fluff about GA announcement |
Supabase Discord Community | Fastest way to get help when shit breaks at 3AM |
GitHub Issues | Where you'll find the bugs you're actually experiencing |
Stack Overflow | Hit or miss, but worth checking for production gotchas |
Related Tools & Recommendations
Firebase Realtime Database - Keeps Your Data In Sync
competes with Firebase Realtime Database
Stop Stripe from Destroying Your Serverless Performance
Cold starts are killing your payments, webhooks are timing out randomly, and your users think your checkout is broken. Here's how to fix the mess.
Supabase + Next.js + Stripe: How to Actually Make This Work
The least broken way to handle auth and payments (until it isn't)
Claude API + Next.js App Router: What Actually Works in Production
I've been fighting with Claude API and Next.js App Router for 8 months. Here's what actually works, what breaks spectacularly, and how to avoid the gotchas that
Fast React Alternatives That Don't Suck
integrates with React
Stripe Terminal React Native Production Integration Guide
Don't Let Beta Software Ruin Your Weekend: A Reality Check for Card Reader Integration
Converting Angular to React: What Actually Happens When You Migrate
Based on 3 failed attempts and 1 that worked
Fix Flutter Performance Issues That Actually Matter in Production
Stop guessing why your app is slow. Debug frame drops, memory leaks, and rebuild hell with tools that work.
Flutter vs React Native vs Kotlin Multiplatform: Which One Won't Destroy Your Sanity?
The Real Question: Which Framework Actually Ships Apps Without Breaking?
Tauri vs Electron vs Flutter Desktop - Which One Doesn't Suck?
integrates with Tauri
Anthropic Raises $13B at $183B Valuation: AI Bubble Peak or Actual Revenue?
Another AI funding round that makes no sense - $183 billion for a chatbot company that burns through investor money faster than AWS bills in a misconfigured k8s
Major npm Supply Chain Attack Hits 18 Popular Packages
Vercel responds to cryptocurrency theft attack targeting developers
Vercel AI SDK 5.0 Drops With Breaking Changes - 2025-09-07
Deprecated APIs finally get the axe, Zod 4 support arrives
I Ditched Vercel After a $347 Reddit Bill Destroyed My Weekend
Platforms that won't bankrupt you when shit goes viral
Docker Desktop Hit by Critical Container Escape Vulnerability
CVE-2025-9074 exposes host systems to complete compromise through API misconfiguration
Yarn Package Manager - npm's Faster Cousin
Explore Yarn Package Manager's origins, its advantages over npm, and the practical realities of using features like Plug'n'Play. Understand common issues and be
Nuxt - I Got Tired of Vue Setup Hell
Vue framework that does the tedious config shit for you, supposedly
Framework Wars Survivor Guide: Next.js, Nuxt, SvelteKit, Remix vs Gatsby
18 months in Gatsby hell, 6 months testing everything else - here's what actually works for enterprise teams
PostgreSQL Alternatives: Escape Your Production Nightmare
When the "World's Most Advanced Open Source Database" Becomes Your Worst Enemy
Zapier - Connect Your Apps Without Coding (Usually)
integrates with Zapier
Recommendations combine user behavior, content similarity, research intelligence, and SEO optimization