@trigger.dev/supabase package provides an integration that wraps the Supabase Management API, allow you to run tasks that can manage your Supabase Orgs, Projects, and Databases.
It also provides the ability to trigger jobs based on changes in your Supabase database through the use of Supabase Database Webhooks.
Usage
There are two different ways to authenticate with the Supabase Management API, either using a Personal Access Token or through OAuth provided by Trigger.dev.Personal Access Token
To use the Management API integration with a Personal Access Token, head over to your account tokens page and click the “Generate New Token” button. Once you’ve copied the token you should save it to an environment variable in your project, for exampleSUPABASE_TOKEN and then use it in the SupabaseManagementAPI constructor:
SUPABASE_TOKEN environment variable set in your project and keep it secret, as it provides full access to your Supabase account.
OAuth
To use the Management API integration with Supabase OAuth, you’ll need to create a new integration in the Trigger.dev dashboard and authorize it with your Supabase account. Once you’ve done that, you can use theSupabaseManagementAPI constructor with the matching id of the integration:
Jobs & Tasks
Using theSupabaseManagement integration, you can run any of the Management API endpoints as a task inside a job. For example, to create a new Supabase project:
Triggers
TheSupabaseManagement integration also provides the ability to trigger jobs based on changes in your Supabase database through the use of Supabase Database Webhooks.
Enable Database Webhooks
Manually enabling database webhooks are only needed if you are using
@trigger.dev/supabase at
version 2.0.2 or earlier. If you are using 2.0.3 or later, this is done automatically for you.
You’ll have to do this for each Supabase project you want to use webhooks with.
You don’t actually need to create any webhooks yourself, our integration will take care of that
part for you.
Usage
To use this feature, you’ll first initialize adb instance, passing in your Supabase project ID (or URL):
db instance to add a trigger to run a job when a row is inserted, updated, or deleted from a table:
filter object:
on trigger:
We will only create at most 1 database webhook per table, to limit resource usage when writing to
your database. This means we cannot support scoping updated triggers to specific columns.

