
Supabase Realtime Has Free WebSocket Subscriptions — Here's How to Build Live Features
Building real-time features usually means setting up WebSocket servers, managing connections, and handling reconnects. Supabase Realtime does all of this for you. What is Supabase Realtime? Supabase Realtime lets you listen to database changes, broadcast messages between clients, and sync presence (who is online) — all over WebSockets, all for free. Three Realtime Features 1. Database Changes (Postgres Changes) import { createClient } from ' @supabase/supabase-js ' ; const supabase = createClient ( SUPABASE_URL , SUPABASE_KEY ); // Listen to ALL changes on the messages table const channel = supabase . channel ( ' messages ' ) . on ( ' postgres_changes ' , { event : ' * ' , // INSERT, UPDATE, DELETE schema : ' public ' , table : ' messages ' , }, ( payload ) => { console . log ( ' Change: ' , payload . eventType , payload . new ); }) . subscribe (); // Listen to specific events supabase . channel ( ' new-orders ' ) . on ( ' postgres_changes ' , { event : ' INSERT ' , schema : ' public '
Continue reading on Dev.to Webdev
Opens in a new tab



