Module realtime

Source
Expand description

Realtime module for Supabase WebSocket subscriptions

This module provides cross-platform WebSocket support using proper abstractions:

  • Native: Uses tokio-tungstenite with TLS support
  • WASM: Uses web-sys WebSocket API through the browser

§Usage

use supabase::Client;
use supabase::realtime::RealtimeEvent;

let client = Client::new("your-url", "your-key")?;
let realtime = client.realtime();

// Connect to realtime
realtime.connect().await?;

// Subscribe to table changes
let subscription_id = realtime
    .channel("posts")
    .table("posts")
    .event(RealtimeEvent::All)
    .subscribe(|message| {
        println!("Received update: {:?}", message);
    })
    .await?;

// Later, unsubscribe
realtime.unsubscribe(&subscription_id).await?;

Structs§

ChannelBuilder
Builder for channel subscriptions
Realtime
Realtime client for WebSocket subscriptions
RealtimeMessage
Realtime message received from Supabase
RealtimePayload
Payload of a realtime message
Subscription
Subscription information
SubscriptionConfig
Configuration for subscriptions

Enums§

RealtimeEvent
Realtime event types for filtering subscriptions