Supabase Driver
The Supabase Driver is a signaling driver that uses Supabase Realtime to relay signaling messages between peers via your Supabase project. It is a good choice when you want browser-to-device communication over infrastructure you already manage.
To use the Supabase Driver, you must have a Supabase project with Realtime enabled. The driver uses a simple pub/sub pattern: clients subscribe to channels based on a prefix, and the server relays messages between clients in the same channel. Each channel represents a peer room where signaling messages are exchanged between peers in that room.
Usage
To use the Supabase Driver, import the driver from Peerix, create a Supabase client, and pass that client to the driver instance:
import { SupabaseDriver } from 'peerix';
import { createClient } from '@supabase/supabase-js';
// connect to your Supabase project
const supabase = createClient('your_project_url', 'your_supabase_api_key');
// create the Supabase driver instance
const driver = new SupabaseDriver({
// the Supabase client instance
supabase,
// optional prefix for signaling channels
prefix: 'peerix:',
});All peers that connect to the same Supabase project and use the same prefix can discover each other and exchange signaling messages.
Installation
You need the @supabase/supabase-js package in the browser to use the Supabase Driver.
npm install @supabase/supabase-js