DEV Community

Alex Spinov
Alex Spinov

Posted on

Neon Has a Free API: The Serverless Postgres That Scales to Zero and Branches Your Database Like Git

Your Postgres instance runs 24/7 even when nobody's using your app. That's $50-200/mo for a database that's idle 90% of the time. Neon is serverless Postgres — it scales to zero when idle (you pay nothing), wakes up in 150ms on the first query, and lets you branch your entire database like a git branch.

What Neon Actually Does

Neon is a fully managed serverless Postgres provider. It separates storage from compute, which enables two killer features: scale-to-zero (compute shuts down when idle, restarts on demand) and database branching (instant copy-on-write clones of your entire database).

You get a standard Postgres connection string. Any Postgres client, ORM, or tool works unchanged. But underneath, Neon's architecture means you only pay for what you use, and you can create instant database copies for development, testing, or preview environments.

Free tier: 0.5 GB storage, 1 project with 10 branches, always-available compute. Paid plans start at $19/mo for autoscaling.

Quick Start

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

# Standard Postgres connection
psql 'postgresql://user:password@ep-cool-name-123.us-east-2.aws.neon.tech/neondb'
Enter fullscreen mode Exit fullscreen mode

Using Node.js:

import { neon } from '@neondatabase/serverless';

const sql = neon(process.env.DATABASE_URL);

// Standard SQL — it's just Postgres
const users = await sql`
  SELECT id, name, email
  FROM users
  WHERE created_at > NOW() - INTERVAL '7 days'
  ORDER BY created_at DESC
`;
Enter fullscreen mode Exit fullscreen mode

Neon's serverless driver works in edge functions (Cloudflare Workers, Vercel Edge):

export default {
  async fetch(request, env) {
    const sql = neon(env.DATABASE_URL);
    const posts = await sql`SELECT * FROM posts LIMIT 10`;
    return Response.json(posts);
  }
};
Enter fullscreen mode Exit fullscreen mode

3 Practical Use Cases

1. Database Branching for Preview Environments

# Create a branch from production
neonctl branches create --name preview-feature-auth \
  --parent main --project my-project

# Get the branch connection string
neonctl connection-string preview-feature-auth
# postgresql://user:pass@ep-branch-123.neon.tech/neondb
Enter fullscreen mode Exit fullscreen mode

Instant copy of your production database — no dump/restore, no waiting. Use it for PR preview environments:

# GitHub Actions
- name: Create Neon branch
  run: |
    BRANCH=$(neonctl branches create --name pr-${{ github.event.number }})
    echo "DATABASE_URL=$BRANCH" >> $GITHUB_ENV

- name: Run migrations
  run: npx prisma migrate deploy

- name: Run tests
  run: npm test
Enter fullscreen mode Exit fullscreen mode

2. Scale-to-Zero for Dev/Staging

// No special configuration needed
// Neon automatically:
// 1. Suspends compute after 5 min idle (free tier)
// 2. Resumes in ~150ms on next query
// 3. You pay $0 during idle periods

const sql = neon(process.env.DEV_DATABASE_URL);
// First query after idle: ~150ms (cold start)
// Subsequent queries: ~5-20ms (normal Postgres latency)
Enter fullscreen mode Exit fullscreen mode

3. Point-in-Time Restore

# Restore database to any point in the last 7 days (free) or 30 days (paid)
neonctl branches create --name restore-point \
  --parent main \
  --restore-point '2026-03-27T14:30:00Z'

# Now you have a branch with your database state from that exact moment
Enter fullscreen mode Exit fullscreen mode

Accidentally deleted a table? Restore to 5 minutes before the incident.

Why This Matters

Neon makes Postgres economics match serverless architecture. Pay nothing when idle, scale automatically under load, branch instantly for every PR. For startups and indie developers, this means production-grade Postgres without the fixed monthly cost.

The branching feature alone changes development workflows — every developer, every PR, every test suite gets its own full database copy at zero cost.


Need custom data extraction or web scraping solutions? I build production-grade scrapers and data pipelines. Check out my Apify actors or email me at spinov001@gmail.com for custom projects.

Follow me for more free API discoveries every week!

Top comments (0)