This guide will show you how to trigger a task from a Supabase edge function, and then view the run in our dashboard.
Optional step 1: create a new Supabase project
Optional step 2: create a package.json file
package.json
file (e.g. if you are using Deno), create it manually in your project’s root folder.package.json
file you can skip this step.Run the CLI `init` command
/trigger
folder and give you an example task.Run this command in the root of your project to get started:trigger.config.ts
file in the root of your project./trigger
directory./trigger
directory with an example task, /trigger/example.[ts/js]
.Run the CLI `dev` command
dev
command runs a server for your tasks. It watches for changes in your /trigger
directory and communicates with the Trigger.dev platform to register your tasks, perform runs, and send data back and forth.It can also update your @trigger.dev/*
packages to prevent version mismatches and failed deploys. You will always be prompted first.Perform a test run using the dashboard
dev
command spits out various useful URLs. Right now we want to visit the Test page .You should see our Example task in the list , select it. Most tasks have a “payload” which you enter in the JSON editor , but our example task doesn’t need any input.Press the “Run test” button .View your run
Create a new Supabase edge function
edge-function-trigger
.In your project, run the following command in the terminal using the Supabase CLI:Update the edge function code
edge-function-trigger/index.ts
file with the following:type
from the task.trigger
folder use Node, so they must stay in there or they will not run,
especially if you are using a different runtime like Deno. Also do not add “npm:
” to imports
inside your task files, for the same reason.Deploy your edge function using the Supabase CLI
--no-verify-jwt
removes the JSON Web Tokens requirement from the authorization header. By
default this should be on, but it is not strictly required for this hello world example.https://supabase.com/dashboard/project/<your-project-id>/functions
your-project-id
with your actual project ID.prod
secret key from the API keys page.
TRIGGER_SECRET_KEY
with the pasted value of your Trigger.dev prod
secret key.
Deploy your 'Hello World' task
hello-world
task to Trigger.dev cloud.Trigger a prod run from your deployed edge function
edge-function-trigger
URL.https://supabase.com/dashboard/project/<your-project-id>/functions
your-project-id
with your actual project ID.edge-function-trigger
, copy the URL, and paste it into a new window in your browser.Once loaded you should see ‘OK’ on the new screen.hello-world
task.Congratulations, you have run a simple Hello World task from a Supabase edge function!