Prerequisites
You are about to create a simple Supabase Edge Function that logs a message to the console. You’ll trigger this function by setting up a webhook sink in Sequin that sends a HTTP POST request to the function’s URL with the payload of the database row that changed. You’ll need the following:- A Supabase account
- Sequin installed locally
- A Supabase database connected to Sequin
Create a Supabase Edge Function
Create a new edge function
Using the Supabase CLI, create a new edge function:This will create a new TypeScript function in the
supabase/functions/webhook-handler directory.Add code to process webhook requests
Replace the contents of This function will:
supabase/functions/webhook-handler/index.ts with:- Parse the incoming webhook payload from Sequin
- Log the database change details
- Allow you to add custom business logic if you’d like
- Return a success/error response
Test the function locally
Start the function locally using the Supabase CLI:The function will be available at
http://localhost:54321/functions/v1/webhook-handlerDeploy the edge function and retrieve the URL
Using the Supabase CLI, deploy your edge function:Once deployed, you can retrieve the URL of the edge function by logging into the Supabase Dashboard and navigating to the Edge Functions page. The URL will be in the format:You can also get the URL by running:
Create a Sequin webhook sink
Create a new sink
Navigate to the “Sinks” tab, click the “Create Sink” button, and select “Webhook Sink”.
Select source tables
Select the schemas and tables you want to capture changes from (i.e
public.users or public).Add filters (optional)
Add filters to the sink to control which database changes are sent to your webhook endpoint.
Configure message grouping
Under “Message grouping”, leave the default option selected to ensure events for the same row are sent to your webhook endpoint in order.
Configure sink settings
Under “Webhook Sink configuration” leave the defaults:
- Leave the default value of
30000 msfor “Request timeout” as this is more than enough time for your function to process the request - Leave the default value of
1for “Batch size” for now to ensure each change is processed individually.
Configure HTTP endpoint
Add your Supabase edge function URL and add an
Authorization header with the value Bearer YOUR_SUPABASE_ANON_KEY.The
Authorization header is required to authenticate the request with the edge function. You can find your SUPABASE_ANON_KEY in the “Settings” > “API” page in the Supabase Dashboard. If you don’t want to authenticate your request (i.e. make the edge function public), you can deploy the edge function with the --no-verify-jwt flag.Test end-to-end
Trace the change in the Sequin dashboard
In the Sequin console, open the “Messages” tab on your webhook sink and confirm that a message was delivered.
You’ve successfully triggered a Supabase Edge Function from a database change!
Next steps
From here, you may want to:- Refine your webhook sink by using more specific filters. Perhaps you can move logic out of your edge function and into your consumer filters.
- Use Sequin’s replay and backfill features to run historical data through your edge function.
- Use Sequin’s observability features to monitor and debug your webhooks and triggers.

