Preview environments
Each pull request gets its own Neon branch with its migrations, a schema diff comment, and a preview on Vercel or Railway.
Projects with --infra neon (Starter v0.19.0 or newer) have .github/workflows/preview.yml. For each pull request, it:
- creates a Neon branch,
preview/pr-<number>: a copy of the production branch made in seconds, which shares its storage until it changes. Later pushes reuse it; - applies the pull request's migrations to the branch;
- comments the schema diff between the branch and production on the pull request, so a reviewer sees each table and column the pull request changes;
- deploys a preview against the branch on Vercel or Railway, once that platform's token is set;
- posts one comment with the app's stack (such as Next.js, or React + Vite + Hono (TypeScript)), the database branch, and the preview URLs, updated on each push;
- deletes the branch and the Railway environment when the pull request is merged or closed.
A new push replaces the preview being made, and closing waits for it, so nothing is left behind. Pull requests from forks and from Dependabot get no preview, since GitHub gives them no secrets (Dependabot's are skipped from Starter v0.24.1 on).
Turn it on
In GitHub, open the repository's Settings, then Secrets and variables, then Actions:
| Name | Kind | Value |
|---|---|---|
NEON_API_KEY | Secret | An API key from the Neon console: Account settings, then API keys (or an organization's). |
NEON_PROJECT_ID | Variable | The project's ID, from its Settings, then General. |
NEON_PROJECT_ID goes under Variables, not Secrets: the workflow reads it to decide whether to run. A free database the CLI created must be claimed first, since only a Neon account has an API key.
With these two, every pull request gets its branch, migrations, and schema diff. The preview deploy waits for its platform's settings.
The preview deploy
| Name | Kind | Value |
|---|---|---|
VERCEL_TOKEN | Secret | A token from your account settings. |
VERCEL_ORG_ID, VERCEL_PROJECT_ID | Secrets | orgId and projectId from .vercel/project.json, which pnpm clubedge deploy or vercel link writes. |
The preview is a Vercel preview deployment with the project's Preview variables, except DATABASE_URL and DATABASE_URL_DIRECT, which point at the pull request's branch. Set the Preview variables your modules need, or pnpm check:env stops the build. On a team, Vercel's deployment protection asks visitors to sign in to Vercel; turn it off in the project's Settings, then Deployment Protection, to share previews.
Without either platform's settings, pull requests still get their database branch, migrations, and schema diff.
From your machine
pnpm clubedge deploy --preview deploys the current Git branch the same way, without a pull request. It deploys a web app only, so a project without a website gets its previews from this workflow.
How is this guide?