---
title: "A database for every preview environment using Neon, GitHub Actions, and Vercel"
description: "Neon's copy-on-write branching can give every pull request its own production-like Postgres database, avoiding the bottlenecks of shared staging or shared preview databases."
url: "https://swe.quest/articles/a-database-for-every-preview-environment-using-neon-github-actions-and-vercel-dd5fe24cba2d12b5"
canonical: "https://neon.com/blog/branching-with-preview-environments"
source: "Neon"
published: "2023-04-14"
difficulty: "medium"
kind: "How-to"
reading_minutes: 14
tags: ["postgres","ci-cd","deployment","schema-migrations"]
---

# A database for every preview environment using Neon, GitHub Actions, and Vercel

A post on [Neon](https://swe.quest/sources/neon.md), published 2023-04-14, 14 min read, How-to. Original: [https://neon.com/blog/branching-with-preview-environments](https://neon.com/blog/branching-with-preview-environments)

## Summary

Neon's copy-on-write branching can give every pull request its own production-like Postgres database, avoiding the bottlenecks of shared staging or shared preview databases. Branches are isolated, are created in about a second regardless of database size, and bill only for unique data. A GitHub Actions pipeline creates a Neon branch per PR, runs Prisma migrations against it, deploys a Vercel preview wired to that branch, and comments the URLs on the PR. Merging applies migrations to the primary branch, deploys to production and deletes the preview branch.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [CI/CD](https://swe.quest/tags/ci-cd.md) (Reliability & operations)
- [Deployment](https://swe.quest/tags/deployment.md) (Reliability & operations)
- [Schema migrations](https://swe.quest/tags/schema-migrations.md) (Data & databases)

## Prerequisites

- GitHub Actions workflows ([easy posts on CI/CD](https://swe.quest/tags/ci-cd.md?difficulty=easy))
- PostgreSQL basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- Prisma migrations

## Keywords

Neon, GitHub Actions, Vercel, Prisma, Next.js, Neon branching

## Related posts

- [Adopting Neon branching in CI/CD pipelines: a practical story by Shepherd](https://swe.quest/articles/adopting-neon-branching-in-ci-cd-pipelines-a-practical-story-by-shepherd-7c4ee09d2fb5431a.md): Neon · 2024-07-11 · Medium · 5 min read · CI/CD, PostgreSQL, Schema migrations, Testing, Serverless
  Shepherd, an insurtech startup that moved its Alchemist pricing engine from SQLite to Postgres, uses Neon's copy-on-write database branches to give every pull request an ephemeral test database.
- [Branching Postgres databases with the Neon API](https://swe.quest/articles/branching-postgres-databases-with-the-neon-api-3faf0de941bc811a.md): Neon · 2022-12-07 · Medium · 3 min read · PostgreSQL, CI/CD, Testing
  Neon branches are copy-on-write clones of a Postgres database that can be created and deleted through the Neon API, giving CI pipelines an isolated copy of production data for end-to-end tests.
- [Behind Modem.dev’s Product Velocity](https://swe.quest/articles/behind-modem-dev-s-product-velocity-485adbdf853a0161.md): Neon · 2026-01-29 · Medium · 4 min read · PostgreSQL, Schema migrations, CI/CD, Developer productivity
  Modem, a startup building an AI agent that centralizes user feedback from Slack, Discord and GitHub, uses Neon Postgres branching as its development workflow.
- [Fullstack preview environments using Neon and Qovery](https://swe.quest/articles/fullstack-preview-environments-using-neon-and-qovery-5ddb9f5e7c2f931c.md): Neon · 2023-08-11 · Medium · 8 min read · PostgreSQL, CI/CD, Deployment, Serverless
  Each Qovery preview environment can get its own isolated Postgres database by using a Qovery lifecycle job that creates a copy-on-write Neon branch on the environment's Start event and deletes it on Delete.
- [Neon Twin: How to deploy a change tested in Neon to prod in RDS](https://swe.quest/articles/neon-twin-how-to-deploy-a-change-tested-in-neon-to-prod-in-rds-09282f8f58bccb12.md): Neon · 2024-08-15 · Medium · 10 min read · Schema migrations, PostgreSQL, CI/CD, Deployment
  Schema changes tested on Neon database branches can be promoted to an AWS RDS production Postgres database through GitHub Actions that run when a pull request merges.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
