What is Neon?
Neon is a serverless PostgreSQL platform that separates storage from compute. This means your database scales to zero when idle (pay nothing) and instantly scales up when traffic hits. It also supports branching — create a full database copy in milliseconds for development and testing.
Why Neon?
- Free tier — 0.5 GB storage, autoscaling, 1 project
- Scale to zero — no charge when database is idle
- Instant branching — copy-on-write database branches in milliseconds
- Autoscaling — 0.25 to 8 compute units based on load
- 100% PostgreSQL — not a fork, full compatibility
- Neon API — programmatically manage projects, branches, endpoints
Quick Start
# Connect with any PostgreSQL client
psql 'postgresql://user:password@ep-cool-name-123.us-east-2.aws.neon.tech/neondb?sslmode=require'
import psycopg2
conn = psycopg2.connect(
'postgresql://user:password@ep-cool-name-123.us-east-2.aws.neon.tech/neondb?sslmode=require'
)
cur = conn.cursor()
cur.execute('SELECT version();')
print(cur.fetchone()) # PostgreSQL 16.x
Neon API: Manage Databases Programmatically
# Create a new branch (instant database copy)
curl -X POST 'https://console.neon.tech/api/v2/projects/PROJECT_ID/branches' \
-H 'Authorization: Bearer NEON_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"branch": {"name": "feature-checkout"}, "endpoints": [{"type": "read_write"}]}'
# List branches
curl 'https://console.neon.tech/api/v2/projects/PROJECT_ID/branches' \
-H 'Authorization: Bearer NEON_API_KEY'
# Delete branch when done
curl -X DELETE 'https://console.neon.tech/api/v2/projects/PROJECT_ID/branches/BRANCH_ID' \
-H 'Authorization: Bearer NEON_API_KEY'
Database Branching for Development
# Main branch has production data
# Create a branch for development — instant, no data copy
neonctl branches create --name dev/feature-123
# Get connection string
neonctl connection-string dev/feature-123
# Run migrations on the branch
prisma migrate deploy --url $(neonctl connection-string dev/feature-123)
# Test, iterate, then merge or delete
neonctl branches delete dev/feature-123
Use with Prisma
// schema.prisma
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL") // For migrations
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
title String
content String?
author User @relation(fields: [authorId], references: [id])
authorId Int
createdAt DateTime @default(now())
}
Autoscaling Configuration
# Set autoscaling range
neonctl endpoints update ep-cool-name-123 \
--min-cu 0.25 \
--max-cu 4 \
--suspend-timeout 300 # Scale to zero after 5 min idle
Neon vs Alternatives
| Feature | Neon | Supabase | PlanetScale | RDS |
|---|---|---|---|---|
| Scale to zero | Yes | No | Deprecated | No |
| Branching | Instant | No | Yes | Snapshot |
| Free tier | 0.5GB | 500MB | Hobby deprecated | None |
| Autoscaling | 0.25-8 CU | Fixed | Fixed | Manual |
| PostgreSQL | 100% | Yes | MySQL | Yes |
| Serverless driver | Yes | Yes | Yes | No |
Real-World Impact
A dev tools startup ran 50 preview environments for PR reviews, each needing a database. With RDS: $2/hour per instance = $2,400/month for preview DBs alone. After switching to Neon branching: each preview environment gets an instant branch that scales to zero when the PR is closed. Cost: $12/month total. Same functionality, 99.5% cost reduction.
Need serverless databases for your development workflow? I help teams implement efficient database strategies. Contact spinov001@gmail.com or explore my data tools on Apify.
Top comments (0)