Back to blog
InfrastructureDec 1, 2025

Seamless Database Branching with Neon + Vercel

The Dream: True Preview Environments

Vercel's preview deployments are amazing — every PR gets its own URL. But they all share the same database. One wrong migration in a preview can break production.

Neon's database branching solves this.

How It Works

main branch (Git)     →  production DB (Neon)
feature/auth PR       →  preview DB (auto-created)
feature/search PR     →  preview DB (auto-created)

Each preview deployment gets its own database branch, automatically.

Setup

  • Install Neon integration on Vercel
  • Connect your Neon project
  • That's it — Vercel handles the rest
# .github/workflows/neon-cleanup.yml
# Clean up Neon branches when PRs are closed
on:
  pull_request:
    types: [closed]

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- uses: neondatabase/delete-branch-action@v3
with:
project_id: ${{ vars.NEON_PROJECT_ID }}
branch: preview/pr-${{ github.event.number }}
api_key: ${{ secrets.NEON_API_KEY }}

The Three Environments

EnvironmentTriggerDatabase
ProductionPush to mainproduction branch
PreviewPR createdAuto-created branch
DevelopmentLocalvercel-dev branch

Benefits

  • Safe migrations - Test schema changes without risk
  • Isolated data - Each PR has its own data
  • Automatic cleanup - Branches deleted when PRs close

Conclusion

The combination of Vercel + Neon gives you true environment isolation with zero configuration. It's the infrastructure equivalent of "it just works."

Seamless Database Branching with Neon + Vercel - Euclase Blog