Deploy Your First Flow
This guide walks you through deploying your pgflow workers to Supabase.com production for the first time.
Get Your Database Connection String
Section titled “Get Your Database Connection String”Your workers need to connect to the production database:
- Open Supabase Dashboard
- Navigate to Settings → Database
- Scroll to Connection String section
- Copy the Transaction Mode connection string (uses connection pooler)
The connection string looks like:
postgresql://postgres.pooler-yourproject:[YOUR-PASSWORD]@aws-0-us-east-1.pooler.supabase.com:6543/postgresSet Database Secret
Section titled “Set Database Secret”Workers access the database through the EDGE_WORKER_DB_URL environment variable. Set it as a Supabase secret:
npx supabase secrets set EDGE_WORKER_DB_URL="postgresql://postgres.pooler-yourproject:[YOUR-PASSWORD]@aws-0-us-east-1.pooler.supabase.com:6543/postgres"Replace [YOUR-PASSWORD] with your actual database password from the connection string.
Deploy Your Worker
Section titled “Deploy Your Worker”Deploy your Edge Function to Supabase:
npx supabase functions deploy your-worker-nameReplace your-worker-name with your actual worker function name (e.g., flow-worker).
This uploads your worker code and makes it available at:
https://your-project.supabase.co/functions/v1/your-worker-nameStart Your Worker
Section titled “Start Your Worker”Workers don’t start automatically after deployment. Start it with a POST request:
curl "https://your-project.supabase.co/functions/v1/your-worker-name" \ -H "Authorization: Bearer YOUR_ANON_KEY"Finding your ANON key:
- Open Supabase Dashboard
- Navigate to Settings → API
- Copy the
anonpublickey
The worker starts polling for tasks and continues running until it’s stopped or times out.
Set Up the Safety Net
Section titled “Set Up the Safety Net”Edge Functions eventually stop due to platform limits or errors. Set up a pg_cron job to automatically restart workers when they stop.
Follow the safety net setup guide →