Skip to content

Quickstart

See pgflow in action using the GreetUser flow scaffolded during installation.

  1. Open a terminal and start the edge functions server:

    npx supabase functions serve --no-verify-jwt

    Keep this terminal open.

  2. In a new terminal, compile the GreetUser flow:

    npx pgflow@latest compile greetUser

    You should see:

    Successfully compiled flow to SQL
    Migration file created: supabase/migrations/..._create_greetUser_flow.sql
  3. Apply the migration to register the flow in your database:

    npx supabase migrations up
  4. Send an HTTP request to start the scaffolded worker:

    curl http://localhost:54321/functions/v1/greet-user-worker

    You should see worker activity in the edge functions terminal.

  5. 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
    );
  6. After a moment, query the run status:

    SELECT * FROM pgflow.runs
    WHERE flow_slug = 'greetUser'
    ORDER BY started_at DESC
    LIMIT 1;

    You should see status: completed with output:

    {"greeting": "Hello, Alice Smith!"}
Expand for details
  1. Compilation converted your TypeScript flow to a SQL migration
  2. Migration registered the flow structure in Postgres
  3. Worker began polling for tasks on the greetUser queue
  4. Steps executed in dependency order: fullName ran first, then greeting used its output

The GreetUser flow demonstrates the core pgflow pattern - steps with dependencies that pass data between them.

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.

Make sure edge functions are running:

npx supabase functions serve --no-verify-jwt

Register your flow in supabase/functions/pgflow/index.ts and restart the functions server.

Chat with Author