Handling Supabase webhooks in Val Town allows you to run arbitrary logic whenever an INSERT
, UPDATE
, or DELETE
happens in your database. For example, for new user signups you could set up an email, Slack, or Discord notification, or enrich user data with Clay.
Create an HTTP trigger in Val Town
Section titled “Create an HTTP trigger in Val Town”Create a new val using the webhook template, or remix this example val:
Configure webhook(s) in Supabase
Section titled “Configure webhook(s) in Supabase”Enable Database > Webhooks in the Supabase dashboard, which will install as an Integration:
To wire up your HTTP val:
- Click “Create a new hook”
- Name your webhook
- Select what table (e.g. users) and events (e.g. INSERT) to hook into
- Copy your val’s HTTP endpoint and paste it in
- Create a random secret and add it as a header
- Store the secret as an environment variable in your val
Reference Supabase’s database webhooks docs for more information about payloads, monitoring, and local development.
Verify webhooks
Section titled “Verify webhooks”The hard-coded secret we added above is quick but imperfect security. For more robust signature verification, you can reference this supabaseVerifiedWebhook
val.