Realtime Updates

Subscribe to INSERT, UPDATE, and DELETE events — plus broadcast and presence — over a WebSocket. Use the same anon or service_role key as REST.

WebSocket Connection

wss://<project>.wowsqlconnect.com/realtime/v1/websocket?apikey=<wowsql_anon_... or wowsql_service_...>

Auth is always the apikey query param (browsers cannot set WebSocket headers). Missing key closes 4001; invalid key closes 4003 (do not reconnect on 4003).

Enable a table

Postgres change events require the table to be enabled first:

POST /realtime/v1/enable
{"schema_name":"public","table_name":"users"}

Channel broadcast and presence do not need a Postgres trigger. Payloads are capped at 64 KiB. Multi-replica deployments need REDIS_URL.

Subscribe with the SDK

const channel = client.realtime.channel('chat')
channel
  .on('postgres_changes', { event: '*', schema: 'public', table: 'users' }, (payload) => {
    console.log(payload.event, payload.new || payload.old)
  })
  .subscribe()

Event Types

  • INSERT — New record created
  • UPDATE — Record updated
  • DELETE — Record deleted