Javascript Reference v1.0

Subscribe to channel

Subscribe to realtime changes in your database.

  • Realtime is disabled by default for new Projects for better database performance and security. You can turn it on by managing replication.
  • If you want to receive the "previous" data for updates and deletes, you will need to set REPLICA IDENTITY to FULL, like this: ALTER TABLE your_table REPLICA IDENTITY FULL;
Parameters
    event
    REQUIRED
    SupabaseEventTypes

    The database event which you would like to receive updates for, or you can use the special wildcard * to listen to all changes.

    callback
    REQUIRED
    function

    A callback that will handle the payload that is sent whenever your database changes.


const mySubscription = supabase
  .from('*')
  .on('*', payload => {
    console.log('Change received!', payload)
  })
  .subscribe()