client.channel
Subscribe to realtime changes on a table
Signature
class Client {
channel<T>(table: string): RealtimeChannel
}
Parameters
| Param | Type | Required | Description |
|---|---|---|---|
| table | | yes | Table name to subscribe to |
Examples
import { Client } from '@blueforge/client'
const bf = new Client({ apiKey: process.env.BF_API_KEY!, url: 'https://your-project.blueforge.dev' })
const channel = bf.channel('users')
channel.on('INSERT', (payload) => console.log('new user:', payload.new))
channel.subscribe()
Throws
| Error | Condition |
|---|---|
| API request failed |
| Network issue |
Pitfalls
Real-time requires the table to have realtime enabled via
POST /v1/realtime/enable.
See also
{auto-injected}
Tested against
{auto-injected}