Neon gives you serverless PostgreSQL with branching, autoscaling, and a management API — and the free tier includes 0.5GB storage.
The Management API
# Create a project
curl -X POST 'https://console.neon.tech/api/v2/projects' \
-H "Authorization: Bearer $NEON_API_KEY" \
-d '{"project": {"name": "my-saas"}}'
# Create a branch (instant database copy!)
curl -X POST 'https://console.neon.tech/api/v2/projects/PROJECT_ID/branches' \
-H "Authorization: Bearer $NEON_API_KEY" \
-d '{"branch": {"name": "feature-auth", "parent_id": "main"}}'
Database Branching — Git for Databases
import { neon } from '@neondatabase/serverless'
// Production branch
const prodDb = neon(process.env.DATABASE_URL)
// Create a preview branch for each PR
const previewDb = neon(process.env.PREVIEW_DATABASE_URL)
// Both have the same schema and data — instant, zero-copy
const users = await prodDb`SELECT count(*) FROM users`
const previewUsers = await previewDb`SELECT count(*) FROM users`
// Same data, different branches!
Serverless Driver — HTTP Queries
import { neon } from '@neondatabase/serverless'
const sql = neon(process.env.DATABASE_URL)
// Tagged template queries (SQL injection safe)
const users = await sql`SELECT * FROM users WHERE active = ${true}`
// With parameters
const [user] = await sql`
INSERT INTO users (name, email)
VALUES (${name}, ${email})
RETURNING *
`
// Transaction
const results = await sql.transaction([
sql`UPDATE accounts SET balance = balance - 100 WHERE id = 'alice'`,
sql`UPDATE accounts SET balance = balance + 100 WHERE id = 'bob'`
])
Drizzle ORM Integration
import { drizzle } from 'drizzle-orm/neon-http'
import { neon } from '@neondatabase/serverless'
const sql = neon(process.env.DATABASE_URL)
const db = drizzle(sql)
const activeUsers = await db.select()
.from(users)
.where(eq(users.active, true))
.orderBy(desc(users.createdAt))
.limit(10)
Autoscaling — Scale to Zero
Neon automatically scales your compute:
- Active queries → scales up instantly
- No queries for 5 minutes → scales to zero ($0 cost)
- Cold start → ~500ms (vs hours for traditional RDS)
Real-World Use Case
A SaaS company was paying $300/month for RDS PostgreSQL that sat idle 95% of the time (dev/staging environments). They migrated to Neon: production runs on autoscaling compute, each dev gets their own branch (instant, shared storage), staging is a branch too. Monthly bill dropped from $300 to $19.
Neon made PostgreSQL act like a serverless database should.
Build Smarter Data Pipelines
Need to scrape websites, extract APIs, or automate data collection? Check out my ready-to-use scrapers on Apify — no coding required.
Custom scraping solution? Email me at spinov001@gmail.com — fast turnaround, fair prices.
Top comments (0)