Need a PostgreSQL database that scales to zero and costs nothing for side projects? Neon is the answer.
What is Neon?
Neon is serverless PostgreSQL. It separates storage from compute, scales to zero when idle, and branches your database like Git branches code.
Free Tier
- 0.5 GB storage
- 24/7 availability for primary branch
- Autoscaling from 0 to 2 CU
- Unlimited branches
- 100 hours of non-primary branch compute
Quick Start
# Sign up at neon.tech, create a project, get connection string
# Then connect from any PostgreSQL client
bun add @neondatabase/serverless
import { neon } from "@neondatabase/serverless";
const sql = neon(process.env.DATABASE_URL!);
// Query directly
const users = await sql`SELECT * FROM users WHERE active = true`;
console.log(users);
// Parameterized queries (SQL injection safe)
const user = await sql`SELECT * FROM users WHERE id = ${userId}`;
With Drizzle ORM
import { drizzle } from "drizzle-orm/neon-http";
import { neon } from "@neondatabase/serverless";
import { users } from "./schema";
const sql = neon(process.env.DATABASE_URL!);
const db = drizzle(sql);
const allUsers = await db.select().from(users);
Database Branching (Killer Feature)
# Create a branch (instant copy of your database)
neonctl branches create --name feature/new-schema
# Each branch has its own connection string
# Perfect for:
# - Preview deployments (each PR gets its own database)
# - Testing migrations before applying to production
# - Development environments
Serverless Driver (Edge-Compatible)
// Works on Cloudflare Workers, Vercel Edge, Deno Deploy
import { neon } from "@neondatabase/serverless";
export default {
async fetch(request: Request): Promise<Response> {
const sql = neon(process.env.DATABASE_URL!);
const result = await sql`SELECT NOW()`;
return new Response(JSON.stringify(result));
},
};
Neon uses WebSocket and HTTP to connect — no TCP needed. This means it works everywhere, including edge functions.
Auto-scaling
Neon scales compute to zero when your database is idle. When a query comes in, it spins up in ~500ms. For the free tier, this means you only pay for what you use.
Neon vs Alternatives
| Feature | Neon | Supabase | PlanetScale | Railway |
|---|---|---|---|---|
| Engine | PostgreSQL | PostgreSQL | MySQL | PostgreSQL |
| Serverless | Yes | No | Yes | No |
| Branching | Yes | No | Yes | No |
| Scale to Zero | Yes | No | Yes | No |
| Edge Driver | Yes | Yes | Yes | No |
| Free Storage | 0.5 GB | 500 MB | 5 GB | 1 GB |
| Free Compute | Auto-suspend | Always on | Auto-suspend | $5 credit |
Use Cases
- Side projects — free tier is generous, scales to zero
- Preview deployments — each PR gets its own database branch
- Edge functions — serverless driver works everywhere
- Development — branch production data for safe testing
Need data to fill your database? Check out my web scraping actors on Apify Store — extract and load data from any website into Neon. For custom solutions, email spinov001@gmail.com.
Top comments (0)