Edge Runtime Driver Adapters
Prisma ORM provides driver adapters optimized for edge runtimes and serverless platforms. These adapters use HTTP-based connections and are compatible with environments like Cloudflare Workers, Vercel Edge Functions, and other edge platforms.Cloudflare D1 Adapter
The@prisma/adapter-d1 package enables usage of Cloudflare D1, Cloudflare’s serverless SQLite database.
Installation
Usage in Cloudflare Workers
Wrangler Configuration
Configure your D1 database binding inwrangler.toml:
JavaScript Example
Features
- Cloudflare Workers runtime support
- SQLite compatibility
- HTTP-based queries (no TCP connections)
- Automatic connection management
- Full Prisma Client API support
Limitations
- Transactions are not supported (D1 limitation)
- Interactive transactions (
$transaction) will throw an error - No migration execution from Workers (use Wrangler CLI)
Migrations
Migrations must be applied using the Wrangler CLI, not from your Worker:Local Development
Test your Worker locally with Wrangler:PlanetScale Adapter
The@prisma/adapter-planetscale package enables usage of PlanetScale’s serverless driver for MySQL databases over HTTP.
Installation
Usage
Node.js 18+
Node.js 18 and later include built-infetch, so you don’t need undici:
Configuration Options
The adapter accepts PlanetScale client configuration:Connection String Format
Update your connection string to use PlanetScale’s HTTP endpoint:aws.connect.psdb.cloud as the host for HTTP connections.
Transaction Support
The adapter supports transactions:Isolation Levels
Supported isolation levels:READ UNCOMMITTEDREAD COMMITTEDREPEATABLE READ(default)SERIALIZABLE
Edge Runtime Support
The adapter works in edge runtimes:Vercel Edge Functions
Cloudflare Workers
Features
- HTTP-based connections (no TCP required)
- Edge runtime compatible
- Full transaction support
- Savepoints for nested transactions
- Improved connection reliability and performance with HTTP/3
Performance Benefits
- Faster MySQL with HTTP/3
- Reduced connection overhead in serverless environments
- No connection pooling required
Limitations
- Requires PlanetScale database
- Must use HTTP connection endpoint (
aws.connect.psdb.cloud)
Edge Runtime Comparison
| Feature | Cloudflare D1 | PlanetScale |
|---|---|---|
| Database | SQLite | MySQL |
| Protocol | HTTP | HTTP |
| Transactions | No | Yes |
| Savepoints | No | Yes |
| Platform | Cloudflare Workers | Any edge runtime |
| Migration Execution | Wrangler CLI only | Standard Prisma Migrate |
| Best For | Cloudflare-native apps | Multi-platform edge apps |
Other Edge-Compatible Adapters
These adapters also support edge runtimes:- Neon HTTP mode: PostgreSQL over HTTP
- libSQL/Turso: SQLite over HTTP with edge support