Broadcast from the database

Send a message to a channel from SQL, for example inside a trigger.

SQL
select realtime.send('{"status": "shipped"}'::jsonb, 'order-update', 'orders', false);

#From a trigger

SQL
create function public.notify_order() returns trigger language plpgsql as $$
begin
  perform realtime.send(to_jsonb(new), 'order-update', 'orders', false);
  return new;
end $$;

create trigger order_updated
  after update on public.orders
  for each row execute function public.notify_order();

Clients listening on the orders channel for the order-update event receive the new row.