supabase-webhooks-events
Installation
SKILL.md
Supabase Webhooks & Database Events
Overview
Supabase offers four complementary event mechanisms: Database Webhooks (trigger-based HTTP calls via pg_net), supabase_functions.http_request() (call Edge Functions from triggers), Postgres LISTEN/NOTIFY (lightweight pub/sub), and Realtime postgres_changes (client-side event subscriptions). This skill covers all four patterns with production-ready code including signature verification, idempotency, and retry handling.
Prerequisites
- Supabase project (local or hosted) with
supabaseCLI installed pg_netextension enabled: Dashboard > Database > Extensions > search "pg_net" > Enable@supabase/supabase-jsv2+ installed for client-side patterns- Edge Functions deployed for webhook receiver patterns
Authentication
Both directions of a webhook are authenticated:
- Outbound (trigger → Edge Function): the trigger sends an
Authorization: Bearer <service_role_key>header. Store the key in a Postgres setting (app.settings.service_role_key) or Supabase Vault — never inline it in a committed migration. - Inbound (Edge Function receiver): verify an HMAC-SHA256 signature against a shared
WEBHOOK_SECRET(read fromDeno.env) using a constant-time comparison, and reject mismatches with401. See signature-verification.md.