| title | Deploy Your First Flow | ||
|---|---|---|---|
| description | Step-by-step guide to deploying pgflow workers to Supabase.com production for the first time | ||
| sidebar |
|
||
| banner |
|
import { Aside, CardGrid, LinkCard } from "@astrojs/starlight/components";
This guide walks you through deploying your pgflow workers to Supabase.com production for the first time.
Before deploying to production: - You have a working local development environment - Your flows are compiled and tested locally - You have a Supabase project (free or paid tier) The `pgflow` ControlPlane function is for local compilation only. You do not need to deploy it to production yet - only deploy your worker functions.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/postgres
:::note[Why Transaction Mode?] Transaction Mode uses connection pooling (port 6543), which is required for Edge Functions. The pooler efficiently manages database connections in serverless environments. :::
If your password contains special characters (`@`, `&`, `:`, etc.), you'll need to URL-encode it. See [Connection String Encoding](/deploy/connection-string/) for details.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.
:::caution[Keep Your Password Secure]
- Never commit passwords to git
- Never share passwords in public channels
- Use the encoded password if it contains special characters :::
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-name
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
:::note
Production Edge Functions have JWT verification enabled by default. Currently, workers use the anon key for self-respawning. Enhanced authentication using a dedicated secret key is planned for future releases.
:::
The worker starts polling for tasks and continues running until it's stopped or times out.
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 →
**Your workers will eventually stop without a safety net.** This is especially critical for production where workflow reliability matters.The safety net takes 2 minutes to set up and prevents hours of debugging why workflows stopped running.