Menu

Post image 1
Post image 2
1 / 2
0

Supabase Webhooks — Event-driven Backend With pg_net

DEV Community·kanta13jp1·about 1 month ago
#dmGJLOUW
Reading 0:00
15s threshold

Supabase Webhooks — Event-driven Backend With pg_net Supabase Webhooks let database INSERT/UPDATE/DELETE events trigger Edge Functions or external APIs automatically. Combined with pg_net and pg_cron , you can build a powerful event-driven backend without any extra infrastructure. How It Works DB change (INSERT / UPDATE / DELETE) → pg_net sends async HTTP POST → destination: Edge Function or external API → response saved to net.http_response_queue Enter fullscreen mode Exit fullscreen mode Dashboard Setup Go to Database → Webhooks → Create a new hook Configure: Name : on_task_created Table : tasks Events : INSERT Type : Supabase Edge Functions Function : notify-slack SQL Setup (more flexible) CREATE OR REPLACE FUNCTION notify_on_task_insert () RETURNS trigger LANGUAGE plpgsql AS $$ DECLARE payload jsonb ; BEGIN payload : = jsonb_build_object ( 'type' , TG_OP , 'table' , TG_TABLE_NAME , 'record' , row_to_json ( NEW ), 'old_record' , CASE WHEN TG_OP = 'UPDATE' THEN row_to_json ( OLD ) ELSE NULL END ); PERFORM…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More