1. Using JWT Authentication (Recommended for User-Specific Operations)
A JWT (JSON Web Token) is a string-formatted data container that typically stores user identity and permissions data. Row Level Security policies are based on the information present in JWTs. Supabase JWT docs can be found here. To use JWTs with Supabase, you’ll need to add theSUPABASE_JWT_SECRET
environment variable in your project. This secret is used to sign the JWTs. This can be found in your Supabase project settings under Data API
.
This example code shows how to create a JWT token for a user and initialize a Supabase client with that token for authentication, allowing the task to perform database operations as that specific user. You can adapt this code to fit your own use case.
2. Using Service Role Key (For Admin-Level Access)
The service role key has unlimited access and bypasses all security checks. Only use it when you
need admin-level privileges, and never expose it client-side.
Learn more about Supabase and Trigger.dev
Full walkthrough guides from development to deployment
Edge function hello world guide
Learn how to trigger a task from a Supabase edge function when a URL is visited.
Database webhooks guide
Learn how to trigger a task from a Supabase edge function when an event occurs in your database.
Supabase authentication guide
Learn how to authenticate Supabase tasks using JWTs for Row Level Security (RLS) or service role
keys for admin access.