In the previous lesson, we looked at using Postgres Change Listeners to establish a realtime connection between the database and the client.
So far, the relationship between databases and clients has been predominantly a one-way street, with clients connecting to databases for information and receiving responses.
This model was sufficient for most applications but falls short when we need instant and direct client-to-client communication. In applications like multiplayer gaming, chat rooms, or collaborative editing, low-latency direct client-to-client communication is crucial for a seamless user experience. Storing every interaction in a central database can introduce unnecessary delays and overload the system, especially when the data doesn't need to be persisted for future retrieval.
This is where Supabase's Presence and Broadcast communication shines: it enables real-time data sharing between clients without the need for database round-trips.
What Are Presence and Broadcast?
Presence — a neat feature in Supabase — allows the app to detect and broadcast a user's online/offline status in realtime. We can see an example of Presence on our course page; it shows the number of users reading a chapter or course in realtime.