Neon's database branching lets you instantly create isolated, copy-on-write clones of your database for any task. Just as you create a Git branch for every new feature or bug fix, you can create a parallel database branch. Developers stop overwriting each other's work on a shared staging database, and each development environment starts from a copy of production data.
Switching connection strings for each branch in local development is tedious and error-prone. Two tools help:
- Neon Local is a Docker-based proxy. Your application connects to a single, static
localhostaddress, and Neon Local routes traffic to the Neon branch you choose, or to an ephemeral branch it creates and deletes for you. - The Neon VS Code extension (formerly Neon Local Connect) connects your editor directly to any Neon branch, with a schema explorer, SQL editor, and table data editor, and lets you create and switch branches without leaving the IDE.
In this guide, you'll learn how to:
- Install the Neon VS Code extension and connect it to a branch.
- Use the built-in schema view, SQL editor, and table data editor.
- Create and switch database branches from your IDE.
- Run Neon Local with Docker Compose to get a static
localhostconnection string and ephemeral branches. - Configure your application to use Neon Local in development and Neon directly in production.
Neon Local vs. a local Postgres instance
This guide focuses on tools that connect to your cloud-hosted Postgres database on Neon. Neon Local is a local proxy: it gives you a localhost connection to a Neon branch, so you can use branching without changing connection strings.
This is different from the Local development with Neon guide, which shows you how to run a completely separate, local instance of Postgres for fully offline development.
For most workflows that use Neon's features, the proxy-based approach in this guide is recommended.
Prerequisites
Before you begin, ensure you have the following:
- Neon account: A Neon account on any plan, including the Free plan. If you don't have one, sign up at Neon.
- VS Code: Or any compatible editor based on VS Code, such as Cursor or Windsurf.
- Docker: Docker Desktop installed and running on your machine, for Neon Local. You can download it from docker.com.
- Node.js: Version
18or later to run the example application.
Neon VS Code extension
The Neon VS Code extension connects your editor to a Neon branch and gives you a control panel for your database inside the IDE. It connects directly to Neon, so it doesn't need Docker.
Install the extension
First, install the extension from the Visual Studio Marketplace or OpenVSX.
- Open your editor and navigate to the Extensions view (
Ctrl+Shift+XorCmd+Shift+X). - Search for "Neon - Serverless Postgres".
- Click Install.

You can also install it directly from the marketplace:
Connect to your Neon account
Once installed, a new Neon icon will appear in your Activity Bar.
- Click the Neon icon to open the Neon panel.
- Click Sign in. This opens a browser window to authenticate your Neon account using OAuth.

- Authorize the application to connect to your Neon account.

Once you sign in, the extension also configures the Neon MCP Server for your coding agent.
Connect to a database branch
After authenticating, the extension fetches your Neon projects and branches. It also scans your workspace for existing Neon connection strings and can detect your project and branch automatically.
- Select your Organization and Project.
- Choose the Branch you want to work on (for example,
development). - Click Connect.
Once connected, the panel shows the branch's connection string. The extension connects to existing branches. For an ephemeral branch that's deleted when you're done, or a static localhost connection string that stays the same across branches, use Neon Local.
Extension features
The extension turns your IDE into a database management tool, so you don't need to switch contexts.
Database schema view
Once connected, a Database Schema view appears in the sidebar. This tree view lets you explore your entire database structure: databases, schemas, tables, columns, and relationships (PKs, FKs). Right-click any table for quick actions like Query Table, View Table Data, Truncate, or Drop.

Built-in SQL editor
Execute queries directly in your IDE. Right-click a table and select "Query Table" to open a pre-filled SELECT * query, or open a blank editor from the command palette.
-
View results in a filterable, sortable table.
-
Export data to CSV/JSON.
-
See performance stats and detailed error messages.

Table data management
For quick edits, right-click a table and select "View Table Data" to open a spreadsheet-like interface.
-
Edit rows by clicking the pen (edit) icon next to any row (requires a primary key).
-
Insert and delete rows with dedicated buttons.
-
Paginate through large datasets.
-
Changes are applied to your database immediately.

Branch management from the panel
The Neon panel also handles branch management:
- Create a new branch: Click the Branch dropdown, select Create new branch..., give it a name, and choose a parent. The extension creates the branch and connects you to it.
- Switch branches: Select a different branch from the dropdown. The schema view updates to show the connected branch. Copy that branch's connection string into your
.envfile, or use Neon Local if you want onelocalhoststring for every branch.
Connect your application
Copy the connection string from the extension panel and add it to your project's .env.local file:
DATABASE_URL="postgresql://alex:AbC123dEf@ep-cool-darkness-123456.us-east-2.aws.neon.tech/dbname?sslmode=require&channel_binding=require"Your app now connects directly to the selected Neon branch.
Follow the Typical development workflow section to see how Neon Local fits into day-to-day work.
Neon Local
Use Neon Local when you want a static localhost connection string, ephemeral branches, or a setup that works outside VS Code and in CI/CD.
Neon Local is a Docker-based proxy that connects to your Neon database and exposes it on a local Postgres endpoint. It provides a static connection string (localhost:5432) that routes to the active branch, making it easy to switch branches without changing your code.
Docker compose configuration
Here is a docker-compose.yml that defines your app and the db (Neon Local) service.
services:
app:
build: .
ports:
- '${PORT}:${PORT}'
environment:
- DATABASE_URL="postgres://neon:npg@db:5432/${DB_NAME}?sslmode=no-verify"
depends_on:
- db
db:
image: neondatabase/neon_local:latest
ports:
- '5432:5432'
environment:
- NEON_API_KEY=${NEON_API_KEY}
- NEON_PROJECT_ID=${NEON_PROJECT_ID}
# Choose one of the following:
- BRANCH_ID=${BRANCH_ID} # For existing branches
# - PARENT_BRANCH_ID=${PARENT_BRANCH_ID} # For ephemeral branchesKey environment variables
| Variable | Description | Required | Default |
|---|---|---|---|
NEON_API_KEY | Your Neon API key. | Yes | N/A |
NEON_PROJECT_ID | Your Neon project ID. | Yes | N/A |
BRANCH_ID | Connects to a specific existing branch. Mutually exclusive with PARENT_BRANCH_ID. | No | N/A |
PARENT_BRANCH_ID | Creates an ephemeral branch from a parent. If omitted, uses the project's default branch. | No | Project's default branch |
DELETE_BRANCH | Set to false to prevent branches from being deleted when the container stops. | No | true |
If you need to use the docker run command instead of Docker Compose, see the Neon Local docs.
Advanced configuration
Persistent branches per Git branch
For a workflow where a database branch's lifecycle matches a Git branch, you can configure Neon Local to persist its state.
Add volumes to your db service in docker-compose.yml:
db:
image: neondatabase/neon_local:latest
ports:
- '5432:5432'
environment:
NEON_API_KEY: ${NEON_API_KEY}
NEON_PROJECT_ID: ${NEON_PROJECT_ID}
DELETE_BRANCH: false
volumes:
- ./.neon_local/:/tmp/.neon_local
- ./.git/HEAD:/tmp/.git/HEAD:ro,consistentThis configuration uses your current Git branch name to manage a persistent database branch.
note
This will create a .neon_local directory in your project to store metadata. Be sure to add .neon_local/ to your .gitignore to avoid committing database information.
Git integration using Docker on Mac
If using Docker Desktop for Mac, ensure that your VM settings use gRPC FUSE instead of VirtioFS. There is currently a known bug with VirtioFS that prevents proper branch detection and live updates inside containers.

Typical development workflow
Neon's branching fits Git-based development workflows. When each Git branch has a matching database branch, changes stay isolated, developers don't collide, and production stays clean.
Here’s a practical look at how to use Neon Local in your daily tasks.
The scenario: starting a new task
You've just been assigned a ticket to build a new user profile page. The first step is always to create a new Git branch to isolate your code changes.
git checkout main
git pull
git checkout -b feature/new-user-profileNow that your code is isolated, you need to isolate your database. You have two primary options depending on the scope of your task.
Option 1: Long-lived feature
When to use it: This is the standard approach for most feature work, bug fixes that require review, or any task that will span multiple sessions or involve collaboration. You create a persistent database branch that mirrors the lifecycle of your Git branch.
With the VS Code extension:
- In the Neon panel, click the Branch dropdown menu.
- Select Create new branch....
- Enter a name for your branch. It's good practice to match your Git branch name, like
feature/new-user-profile. - Choose a parent branch to copy data and schema from (e.g.,
productionordevelopment). - The extension creates the branch and connects you to it. Copy the new branch's connection string into your
.envfile.
Option 2: Quick experiment or test
When to use it: Quick bug fixes, running a single test suite, or experimenting with a schema change that you might throw away. Neon Local creates an ephemeral branch when the container starts and deletes it when the container stops. The VS Code extension connects to existing branches, so use Neon Local for this option.
You create an ephemeral branch by specifying a PARENT_BRANCH_ID instead of a BRANCH_ID.
-
In the Neon Console, find the Branch ID of the branch you want to use as a parent (e.g., your
productionordevelopmentbranch). -
In your
docker-compose.yml, configure thedbservice to use this parent ID.services: db: # ... other settings environment: - NEON_API_KEY=${NEON_API_KEY} - NEON_PROJECT_ID=${NEON_PROJECT_ID} - PARENT_BRANCH_ID=<your_parent_branch_id> # Create ephemeral branch from this parent -
Run
docker compose up. Neon Local will create a new, temporary branch from this parent. -
When you're finished, run
docker compose down. Neon Local deletes the ephemeral branch from your Neon project.
Connecting your application conditionally
Your application code needs to switch between connecting to Neon Local for development and your live Neon database for production. The standard way to manage this is by using the NODE_ENV environment variable.
When process.env.NODE_ENV is set to 'development', your application should use the static localhost connection string provided by Neon Local. For any other environment (such as 'production' on platforms like Vercel, AWS, or other cloud providers), your app should use the actual Neon database URL, typically stored in your deployment environment's configuration or secrets on your cloud provider.
The implementation details vary slightly depending on the database driver or ORM you are using.
The Neon serverless driver talks to a Neon database over HTTP or WebSocket. To send this traffic to the Neon Local proxy in development, reconfigure neonConfig to point to localhost.
-
Install Dependencies
npm install @neondatabase/serverless ws -
Configure the connection
import { neon, neonConfig, Pool } from '@neondatabase/serverless'; import ws from 'ws'; let connectionString = process.env.DATABASE_URL || 'postgres://neon:npg@localhost:5432/<database_name>'; if (process.env.NODE_ENV === 'development') { // Point the serverless driver to the local proxy neonConfig.fetchEndpoint = 'http://localhost:5432/sql'; neonConfig.poolQueryViaFetch = true; } // Use the WebSocket constructor for Node.js neonConfig.webSocketConstructor = ws; // Neon supports both HTTP and WebSocket clients. Choose the one that fits your needs: // HTTP Client (sql) // - Best for serverless functions and Lambda environments // - Ideal for stateless operations and quick queries // - Lower overhead for single queries // - Better for applications with sporadic database access export const sql = neon(connectionString); // WebSocket Client (pool) // - Best for long-running applications (like servers) // - Maintains a persistent connection // - More efficient for multiple sequential queries // - Better for high-frequency database operations export const pool = new Pool({ connectionString });
Other languages and drivers
The neonConfig setup is exclusive to the @neondatabase/serverless driver and its wrappers (Drizzle, Prisma adapter) in Node.js environments.
For applications written in other languages (like Python, Go, Ruby, Java, etc.) that use standard Postgres drivers, you can follow the same pattern as the node-postgres (pg) example:
- Read the database connection string from an environment variable.
- In your local development environment, set this variable to
postgres://neon:npg@localhost:5432/<database_name>. - In production, set it to your real Neon connection string.
- You may need to conditionally disable SSL for the local connection.
No other code modifications are necessary.
Summary
You set up the Neon VS Code extension to browse, query, and branch your database from the IDE, and Neon Local with Docker Compose to give your app a static localhost connection and ephemeral branches. As a next step, try the example application that uses Neon Local.
Resources
Need help?
Join our Discord Server to ask questions or see what others are doing with Neon. For paid plan support options, see Support.








