JavaScript: Broadcast a message

Sends a message into the channel.

Broadcast a message to all connected clients to a channel.

Parameters

Examples

Send a message via websocket

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

Send a message via REST

supabase
  .channel('room1')
  .httpSend('cursor-pos', { x: Math.random(), y: Math.random() })