Supabase.Realtime.HTTP (supabase_realtime v0.5.0)

Copy Markdown

HTTP fallback for Supabase Realtime broadcasts.

Sends broadcast messages through the Supabase REST API when the WebSocket connection is not available.

When Does the Fallback Trigger?

All three conditions must be true:

  1. The WebSocket connection status is not :open.
  2. The :http_fallback option is set to true on the connection.
  3. The message being sent is a broadcast message.

Other message types (presence, postgres_changes) are never sent over HTTP. They go into the send buffer and wait for the WebSocket to reconnect.

Example

# Usually called by the Connection module, but can be used directly:
Supabase.Realtime.HTTP.broadcast(client, token, "realtime:room:lobby", "new_msg", %{body: "hi"})

Summary

Functions

Sends a broadcast message via HTTP POST using the Supabase Fetcher.

Functions

broadcast(client, token, topic, event, payload)

@spec broadcast(Supabase.Client.t(), String.t(), String.t(), String.t(), map()) ::
  :ok | {:error, term()}

Sends a broadcast message via HTTP POST using the Supabase Fetcher.

Parameters

  • client - The Supabase.Client struct
  • token - The access token for authorization
  • topic - The channel topic
  • event - The broadcast event name
  • payload - The message payload