Javascript Reference v2.0

Broadcast a message

Sends a message into the channel.

Broadcast a message to all connected clients to a channel.

  • When using REST you don't need to subscribe to the channel
  • REST calls are only available from 2.37.0 onwards
Parameters
    args
    REQUIRED
    object

    Arguments to send to channel

    opts
    Optional
    object

    Options to be used during the send process


supabase
  .channel('room1')
  .subscribe((status) => {
    if (status === 'SUBSCRIBED') {
      channel.send({
        type: 'broadcast',
        event: 'cursor-pos',
        payload: { x: Math.random(), y: Math.random() },
      })
    }
  })