Neon Serverless PostgreSQL
Use Neon for serverless PostgreSQL with branching, autoscaling, and a generous free tier for development.
Overview
Neon's branching feature creates copy-on-write clones of your database, enabling preview environments for pull requests, safe testing of migrations, and instant production snapshots. Branches share storage with the parent, so creating a branch is instant and costs nothing until data diverges. Autoscaling adjusts compute resources based on load, scaling to zero during inactivity for cost efficiency.
The serverless driver is wire-compatible with node-postgres (pg), so existing code works without changes. It supports both pooled connections (for serverless) and direct connections (for long-running processes). Neon provides the Neon Auth extension for automatic JWT validation in PostgreSQL, built-in connection pooling via PgBouncer, and integrations with Vercel, Cloudflare, and AWS Lambda.
Who Is This For?
- Deploy PostgreSQL for serverless applications on Vercel
- Create database branches for preview deployments
- Scale PostgreSQL to zero during development inactivity
- Run instant point-in-time database restores
Installation
npm install @neondatabase/serverless Configuration
import { neon } from "@neondatabase/serverless"
const sql = neon(process.env.DATABASE_URL!)
// Simple query
const posts = await sql`
SELECT * FROM posts
WHERE published = true
ORDER BY created_at DESC
LIMIT 10
`
// With parameters
const user = await sql`
SELECT * FROM users WHERE id = ${userId}
` Explore AI Tools
Discover the best AI tools that complement your skills
Read AI & Design Articles
Tips and trends in the world of design and AI
Related Servers
Sentry Error Tracking
Monitor errors and performance issues in production with Sentry. AI agents can triage alerts and suggest fixes based on stack traces.
PostHog Product Analytics
Track product usage, manage feature flags, and analyze user behavior with PostHog, an open-source product analytics platform.
Database Query Builder
Generate and optimize SQL queries with AI assistance. Build complex queries, analyze execution plans, and improve database performance.