Skip to content

# Run reliable AI Workflows and Background Jobs directly in Supabase

With pgflow, you can seamlessly run workflows directly in Supabase, ensuring reliability and visibility without adding extra infrastructure.
Get Started
Run AI Workflow Demo
Terminal window

    npx pgflow@latest install

Sets up pgflow in your Supabase project. View full setup guide →

## Why pgflow Exists

Section titled “Why pgflow Exists”

While Supabase provides the essential building blocks, pgflow brings enhanced orchestration for advanced workflow management.

#### Developers Instantly Got It

Section titled “Developers Instantly Got It”

Real comments after seeing early demos

←
@Revolutionary-Fact28
(Reddit)

> This looks amazing! I built a system on edge functions but it was very complicated and took so much time. I will probably switch to this.

@CjHuber
(Hacker News)

> Exactly what I was looking for without even knowing it. Thank you for saving me tons of time in my project.

@bctreehugger
(Reddit)

> Amazing work on taking the initiative to build this out. Watching closely and looking forward to using it once my project has a need for it.

@bota01
(Reddit)

> This is very needed and the product looks nice. Can't wait for it to be production ready.

@Danish
(Discord)

> Waiting for your amazing work to be production ready!

@tomaspozo_
(Discord)

> This sounds awesome! Looking forward to see it.

@homj
(Discord)

> Sounds good, I'm looking forward to it!

→

### Have you run into any of these situations?

Section titled “Have you run into any of these situations?”

As apps grow, a little extra coordination can save a lot of engineering time. pgflow steps in right there:

Bringing the Pieces Together

Queues and Edge Functions shine on their own. pgflow wraps them in one orchestration interface, so you write features-not glue code.

Wanting a Bird’s-Eye View

When your workflows span several functions or use multiple cron schedules, it’s handy to follow progress from a single place. pgflow’s approach prioritizes at-a-glance visibility for runs, step states, retries and outputs.

Extra Type Confidence

Define workflows in TypeScript and get a compile-time safety for the data flow between steps.

Keeping Everything Inside Supabase

All state, retries, and dependencies stay in the Postgres database you already trust-no extra services required.

### How pgflow Helps:

Section titled “How pgflow Helps:”

pgflow works in harmony with Supabase’s tools, simplifying orchestration and enabling a more cohesive workflow.

Eliminate manual orchestration with Postgres‑native workflows, zero extra servers, and built‑in reliability

Postgres-Native Orchestration

pgflow handles state transitions, dependencies, and execution control directly inside in your Supabase Postgres database. Everything is self-contained.

Durable Queue-Based Workers

Edge Functions pull tasks from a Postgres queue with automatic retries, back‑offs, and concurrency limits.

Simple, Typed Flow Definitions

You specify flow logic once. pgflow enforces retries, timeouts, and step dependencies without custom plumbing.

Zero Extra Infra, Zero Lock-In

Everything stays in your Supabase project. No extra runtimes, no vendor dashboards.

### What You Can Build with pgflow:

Section titled “What You Can Build with pgflow:”

- AI Workflows: Chain LLMs, scrape data, reason across tools, and recover from failures - all natively in Supabase.
- Background Jobs: Handle emails, file processing, and scheduled tasks with full visibility
- Data Pipelines: Extract, transform, and load data across systems without losing track of progress

## A complete workflow engine built on Postgres

Section titled “A complete workflow engine built on Postgres”

pgflow is a workflow orchestration system with its core state management in your database, combining:

SQL Core

Manage workflow state and transitions natively in Postgres with full ACID compliance

TypeScript DSL

Type-safe workflows with automatic inference and end-to-end compile-time safety.

Edge Worker

Auto-respawning, continuously running worker for low latency, reliable task execution.

CLI Tools

One-command setup: quickly deploy pgflow with automatic DB migrations.

## Type-safe DAG workflows in TypeScript

Section titled “Type-safe DAG workflows in TypeScript”

Define parallel, type-safe DAG workflows effortlessly.

    new Flow<{ url: string }>({  slug: 'analyze_website',})  .step(    { slug: 'website' },    async (input) => await scrapeWebsite(input.run.url)  )  .step(    { slug: 'summary', dependsOn: ['website'] },    async (input) => await summarizeWithAI(input.website.content)  )  .step(    { slug: 'tags', dependsOn: ['website'] },    async (input) => await extractTags(input.website.content)  )  .step(    { slug: 'saveToDb', dependsOn: ['summary', 'tags'] },    async ({ run, summary, tags }) =>      await saveWebsite({        user_id: run.user_id,        website_url: run.url,        summary,        tags,      })  );

## End-to-end workflow orchestration

Section titled “End-to-end workflow orchestration”

Single source of truth

All workflow definitions, state, and execution history stored in your Postgres database-simplifying monitoring and debugging.

Reliable task processing

Automatic retries, timeouts, at-least-once delivery and dead-letter handling built directly into your database.

Supabase-native

Deploy as Edge Functions with automatic restarts and zero-config integration with your existing Supabase project.

Developer experience

Full type inference between workflow steps with IDE autocompletion and compile-time safety for your entire workflow DAG.

## From workflow DSL to execution

Section titled “From workflow DSL to execution”

Create and run workflows with a straightforward process:

1. Define workflows using TypeScript DSL
2. Compile them to SQL migrations
3. Deploy as Supabase Edge Functions
4. Trigger workflows from your app or SQL

The execution system handles the rest-scheduling steps when dependencies complete, retrying failed tasks, and aggregating results automatically.

## Ready to get started?

Section titled “Ready to get started?”
Check Demo app Try out the app that uses pgflow under the hood
Install pgflow Install pgflow into your Supabase project in few minutes