Skip to main content
Drizzle ORM provides first-class support for serverless database platforms, offering optimized drivers and connection pooling designed for serverless environments where traditional database connections don’t work well.

Why Serverless Databases?

Serverless databases solve key challenges in modern applications:
  • No connection limits: HTTP-based connections instead of persistent TCP connections
  • Global edge networks: Deploy your database queries close to users worldwide
  • Pay-per-use pricing: Only pay for actual query execution time
  • Auto-scaling: Handle traffic spikes without manual intervention
  • Zero maintenance: No server management or patching required

Supported Platforms

Drizzle supports all major serverless database platforms with dedicated, optimized drivers.

Neon

Serverless Postgres with instant branching and autoscaling

PlanetScale

Serverless MySQL with branching workflows

Turso (LibSQL)

Edge SQLite with global replication

Vercel Postgres

Postgres designed for Vercel deployments

Neon Postgres

Neon is a serverless Postgres platform with instant branching, autoscaling, and a generous free tier.

Installation

The HTTP driver works everywhere, including edge runtimes, with no WebSocket requirements.
The HTTP driver is perfect for Cloudflare Workers, Vercel Edge Functions, and other environments where WebSockets aren’t available.

WebSocket Connection (Better Performance)

For Node.js and environments with WebSocket support, use the WebSocket driver for lower latency.

Batch Queries

Both HTTP and WebSocket drivers support efficient batch operations:

Row-Level Security with Auth Tokens

Neon supports PostgreSQL Row-Level Security (RLS) with JWT authentication:

PlanetScale MySQL

PlanetScale is a serverless MySQL platform with branching, non-blocking schema changes, and automatic backups.

Installation

Basic Setup

Edge Runtime Compatible

PlanetScale’s HTTP-based driver works in all JavaScript environments:
PlanetScale doesn’t support foreign key constraints at the database level. Use Drizzle’s relational queries for referential integrity in your application.

Schema Design for PlanetScale

Turso (LibSQL)

Turso provides edge-replicated SQLite databases with multi-region support and embedded replicas.

Installation

Remote Database

Embedded Replicas (Best Performance)

Embedded replicas sync a local SQLite database with your remote Turso database for ultra-low latency reads:
Embedded replicas are perfect for Next.js applications deployed to multiple regions. Each region maintains its own local replica for fast reads.

Transactions

Vercel Postgres

Vercel Postgres is a serverless Postgres database integrated with the Vercel platform.

Installation

Setup

Vercel automatically injects POSTGRES_URL and other connection variables when you create a Vercel Postgres database.

Edge Function Example

Connection Pooling

Serverless databases handle connection pooling automatically, but you can optimize configuration:

Neon Pooling

Connection String Options

Most serverless providers support pooling via query parameters:

Best Practices

1

Use connection pooling

Enable connection pooling in your database URL or use a pooling service like PgBouncer to prevent connection exhaustion.
2

Minimize cold starts

Keep your database client initialization outside request handlers when possible:
3

Use prepared statements

For frequently executed queries, use prepared statements to reduce parsing overhead:
4

Batch related queries

Reduce round trips by batching queries when supported:
5

Handle connection errors

Always implement retry logic and graceful degradation:

Migration Strategies

Neon & Vercel Postgres

PlanetScale

PlanetScale uses a branch-based workflow instead of traditional migrations. Use Drizzle Kit to push schema changes to branches.

Turso

Monitoring and Debugging

Enable Query Logging

Custom Logger

Pricing Considerations

  • Free tier: 0.5 GB storage, 1 project
  • Pay for compute time and storage separately
  • Autoscaling to zero when inactive
  • Branch databases are free
  • Free tier: 5 GB storage, 1 billion row reads/month
  • Pay for storage and row reads/writes
  • Branch databases don’t count toward limits during development
  • Free tier: 9 GB total storage across all databases
  • Pay for storage and rows read
  • Edge replicas included in all plans
  • Free tier: 256 MB storage, 60 hours compute/month
  • Integrated billing with Vercel
  • Automatic scaling included

Next Steps

Edge Runtime Guide

Deploy Drizzle to edge networks worldwide

Best Practices

Optimize performance and security

Schema Design

Learn how to design efficient database schemas

Drizzle Kit

Manage migrations and schema changes