This starter is a template for a Next.js project that uses Workflow DevKit with the Postgres World. It follows the Workflow DevKit: Next.js Getting Started Guide to bootstrap a new project, with the few additions necessary to run it with the Postgres world.
-
Clone this example and install dependencies:
git clone https://github.com/vercel/workflow-examples cd workflow-examples/postgres bun install -
Spin up a PostgreSQL database locally or online and obtain the connection URL.
It should look something like
postgresql://<username>:<password>@<host>:<port>/<database>. -
Set the environment variables for the Postgres world:
export WORKFLOW_TARGET_WORLD="@workflow/world-postgres" export WORKFLOW_POSTGRES_URL="postgresql://<username>:<password>@<host>:<port>/<database>"
-
Run the database setup command to create or update the Workflow tables:
bun run migrate
Run this again after upgrading
@workflow/world-postgresso your database schema stays in sync. -
Start the development server:
bun dev
The example uses
instrumentation.tsto start the Postgres world worker when the Next.js server boots. -
Invoke the workflow by
curl:curl -X POST --json '{"email":"hello@example.com"}' http://localhost:3000/api/signup -
Inspect the stored runs if you want to confirm the workflow completed:
bunx workflow inspect runs --backend @workflow/world-postgres
The postgres world is incompatible with Vercel deployments (on Vercel, workflow deployments are automatically configured to use the Vercel World with zero configuration).
Coming soon: instructions on deploying workflows using the Postgres World off-Vercel.