DEV Community

Alex Spinov
Alex Spinov

Posted on

Neon Has a Free Serverless PostgreSQL That Scales to Zero

Traditional PostgreSQL runs 24/7, even when nobody's using your app. Neon is serverless PostgreSQL — it scales to zero when idle and wakes up in milliseconds. Plus: branching your database like Git branches.

What Neon Gives You for Free

  • Serverless PostgreSQL — scales to zero, pay only for usage
  • Database branching — create instant copies for dev/staging/preview
  • 0.5GB storage on free tier (3 projects, 10 branches each)
  • Instant startup — cold start in ~500ms
  • Connection pooling — built-in PgBouncer
  • Autoscaling — scales compute up/down automatically
  • Full PostgreSQL — extensions, functions, triggers all work

Quick Start

# Sign up at neon.tech, create a project, get connection string

# Use with any PostgreSQL client
psql 'postgresql://user:pass@ep-cool-name-123.us-east-2.aws.neon.tech/neondb'
Enter fullscreen mode Exit fullscreen mode

Database Branching (The Killer Feature)

# Create a branch from production (instant, zero-copy)
neonctl branches create --name feature/new-schema --parent main

# Branch has ALL production data (via copy-on-write)
# Modify schema on branch without touching production
psql $BRANCH_URL -c 'ALTER TABLE users ADD COLUMN avatar TEXT;'

# Test your changes
psql $BRANCH_URL -c 'SELECT * FROM users LIMIT 5;'

# Happy? Merge schema changes to production via migration
# Done? Delete the branch
neonctl branches delete feature/new-schema
Enter fullscreen mode Exit fullscreen mode

Branches are instant because they use copy-on-write storage — no data duplication.

Use With Drizzle ORM

import { neon } from '@neondatabase/serverless';
import { drizzle } from 'drizzle-orm/neon-http';
import * as schema from './schema';

const sql = neon(process.env.DATABASE_URL!);
const db = drizzle(sql, { schema });

// Works in Cloudflare Workers, Vercel Edge, etc.
const users = await db.select().from(schema.users).limit(10);
Enter fullscreen mode Exit fullscreen mode

Use With Prisma

datasource db {
  provider  = "postgresql"
  url       = env("DATABASE_URL")
  directUrl = env("DIRECT_URL")  // For migrations
}
Enter fullscreen mode Exit fullscreen mode

Preview Deployments With Branches

# GitHub Action: create a DB branch for every PR
name: Preview
on: pull_request

jobs:
  create-branch:
    runs-on: ubuntu-latest
    steps:
      - uses: neondatabase/create-branch-action@v5
        with:
          project_id: ${{ secrets.NEON_PROJECT_ID }}
          branch_name: pr-${{ github.event.number }}
          api_key: ${{ secrets.NEON_API_KEY }}
Enter fullscreen mode Exit fullscreen mode

Every PR gets its own database branch with production data. Merge PR → delete branch.

Neon vs Supabase vs PlanetScale vs RDS

Feature Neon Supabase PlanetScale RDS
Scale to zero Yes No Deprecated No
Branching Built-in None Built-in None
Free tier 0.5GB 500MB Deprecated None
Cold start ~500ms N/A N/A N/A
Edge support HTTP driver REST API HTTP driver No
Full PostgreSQL Yes Yes MySQL only Yes

The Verdict

Neon is PostgreSQL reimagined for the serverless era. Scale to zero when idle, branch your database like code, and deploy to the edge. If you're building a new project that needs PostgreSQL, Neon's free tier is the best place to start.


Need help building production web scrapers or data pipelines? I build custom solutions. Reach out: spinov001@gmail.com

Check out my awesome-web-scraping collection — 400+ tools for extracting web data.

Top comments (0)