Quickstart
See pgflow in action using the GreetUser flow scaffolded during installation.
-
Start edge functions
Section titled “Start edge functions”Open a terminal and start the edge functions server:
npx supabase functions serve --no-verify-jwtKeep this terminal open.
-
Compile the flow
Section titled “Compile the flow”In a new terminal, compile the GreetUser flow:
npx pgflow@latest compile greetUserYou should see:
Successfully compiled flow to SQLMigration file created: supabase/migrations/..._create_greetUser_flow.sql -
Apply the migration
Section titled “Apply the migration”Apply the migration to register the flow in your database:
npx supabase migrations up -
Start the worker
Section titled “Start the worker”Send an HTTP request to start the scaffolded worker:
curl http://localhost:54321/functions/v1/greet-user-workerYou should see worker activity in the edge functions terminal.
-
Trigger your first flow
Section titled “Trigger your first flow”Open Supabase Studio (http://localhost:54323), go to the SQL Editor, and run:
SELECT * FROM pgflow.start_flow(flow_slug => 'greetUser',input => '{"firstName": "Alice", "lastName": "Smith"}'::jsonb); -
Check the result
Section titled “Check the result”After a moment, query the run status:
SELECT * FROM pgflow.runsWHERE flow_slug = 'greetUser'ORDER BY started_at DESCLIMIT 1;You should see
status: completedwith output:{"greeting": "Hello, Alice Smith!"}
What just happened?
Section titled “What just happened?”Expand for details
- Compilation converted your TypeScript flow to a SQL migration
- Migration registered the flow structure in Postgres
- Worker began polling for tasks on the
greetUserqueue - Steps executed in dependency order:
fullNameran first, thengreetingused its output
The GreetUser flow demonstrates the core pgflow pattern - steps with dependencies that pass data between them.
Iterating on your flow
Section titled “Iterating on your flow”Want to modify the flow structure? Flows are immutable once registered - this protects running workflows.
During development: Delete the flow and recompile. This removes all run data, so only use locally.
In production: Create a versioned flow (e.g., greetUserV2) to preserve history.
Troubleshooting
Section titled “Troubleshooting””Could not connect to ControlPlane”
Section titled “”Could not connect to ControlPlane””Make sure edge functions are running:
npx supabase functions serve --no-verify-jwt“Flow not found”
Section titled ““Flow not found””Register your flow in supabase/functions/pgflow/index.ts and restart the functions server.