Neon's database branching gives every pull request its own isolated Postgres copy. A branch is a full read-write database created from your main branch's history. Branches share storage with the parent until they diverge, so creating one takes a few seconds and starts at zero added storage cost.

Why this works for monorepos

When a monorepo runs integration tests against a shared staging database, parallel CI jobs collide. One PR's migration breaks another PR's tests. A failed teardown leaves leftover data for the next run.

With Neon, each PR gets a clean branch named after the PR or commit SHA. Tests run against real production-shaped data, in isolation, then the branch is deleted when the PR merges or closes.

How to wire it into CI

The simplest path is the official GitHub Action. It creates a branch on PR open, exports the connection string, and deletes the branch on PR close.

- uses: neondatabase/create-branch-action@v5
  id: create-branch
  with:
    project_id: ${{ vars.NEON_PROJECT_ID }}
    branch_name: pr-${{ github.event.number }}
    api_key: ${{ secrets.NEON_API_KEY }}

- run: npm test
  env:
    DATABASE_URL: ${{ steps.create-branch.outputs.db_url }}

For non-GitHub setups, the Neon CLI exposes the same primitives: neon branches create --name pr-123 and neon branches delete pr-123.

Cost control on busy repos

Set a branch time-to-live on paid plans so abandoned PR branches clean themselves up. The Launch and Scale plans charge $1.50/branch-month (prorated hourly) for branches beyond the plan allowance.

Plan limits to know

  • Free: 10 branches per project, 0.5 GB storage per project, 100 CU-hours/month. Fine for prototypes and small repos.
  • Launch: 10 included branches per project, then $1.50/branch-month. Up to 5,000 branches per project.
  • Scale: 25 included branches per project, same overage rate.

See the plans page for full details.

How this compares to other Postgres services

Other managed Postgres offerings provide ways to create per-PR databases, but the cost and speed profile differs:

ProviderPer-PR database mechanismIdle cost
NeonBranch from any point in history, created in seconds, copy-on-write storageScales to zero compute after inactivity
Aurora PostgreSQLAurora cloning uses copy-on-write, but each clone is a separate DB cluster with provisioned ACUsAurora Serverless v2 supports auto-pause to 0 ACUs; storage still charged
RDS for PostgreSQLRestore from snapshot into a new DB instance per PRInstance billed by the hour while running, no scale-to-zero
SupabasePreview branches tied to a GitHub PR; each is a full Supabase environmentBranch Compute billed hourly starting at ~$0.01344/hr on Micro; auto-pauses on inactivity

Neon's branch creation is typically faster (seconds, not minutes) because branches don't require copying data or provisioning a new instance.

Try branching on a PR

Sign up free, install the GitHub Action, and get isolated databases for every pull request.