Skip to main content
Prisma Documentation Docs

Search documentation

Type to search this documentation.

On this pageOverview

Deploying edge functions with Prisma ORM

You can deploy an application that uses Prisma ORM to the edge. Depending on which edge function provider and which database you use, there are different considerations and things to be aware of.

Questions answered in this page
  • Which database drivers work on edge?
  • How do driver adapters affect connections?
  • When to use the Prisma Postgres serverless driver?

Here is a brief overview of all the edge function providers that are currently supported by Prisma ORM:

Provider / Product Supported natively with Prisma ORM Supported with the Prisma Postgres serverless driver
Vercel Edge Functions ✅ (Preview; only compatible drivers) ✅
Vercel Edge Middleware ✅ (Preview; only compatible drivers) ✅
Cloudflare Workers ✅ (Preview; only compatible drivers) ✅
Cloudflare Pages ✅ (Preview; only compatible drivers) ✅
Deno Deploy Not yet ✅

Deploying edge functions that use Prisma ORM on Cloudflare and Vercel is currently in Preview.

Edge functions typically don't use the standard Node.js runtime. For example, Vercel Edge Functions and Cloudflare Workers are running code in V8 isolates. Deno Deploy is using the Deno JavaScript runtime. As a consequence, these edge functions only have access to a small subset of the standard Node.js APIs and also have constrained computing resources (CPU and memory).

In particular, the constraint of not being able to freely open TCP connections makes it difficult to talk to a traditional database from an edge function. While Cloudflare has introduced a connect() API that enables limited TCP connections, this still only enables database access using specific database drivers that are compatible with that API.

Here is an overview of the different database drivers and their compatibility with different edge function offerings:

  • Neon Serverless uses HTTP to access the database. It works with Cloudflare Workers and Vercel Edge Functions.
  • PlanetScale Serverless uses HTTP to access the database. It works with Cloudflare Workers and Vercel Edge Functions.
  • node-postgres (pg) uses Cloudflare's connect() (TCP) to access the database. It is only compatible with Cloudflare Workers, not with Vercel Edge Functions.
  • @libsql/client is used to access Turso databases. It works with Cloudflare Workers and Vercel Edge Functions.
  • Cloudflare D1 is used to access D1 databases. It is only compatible with Cloudflare Workers, not with Vercel Edge Functions.
  • The Prisma Postgres serverless driver uses HTTP and WebSockets. It is supported on Cloudflare Workers, Vercel Edge Functions, and other runtimes with fetch and WebSocket APIs.

There's also work being done on the node-mysql2 driver which will enable access to traditional MySQL databases from Cloudflare Workers and Pages in the future as well.

You can use all of these drivers with Prisma ORM using the respective driver adapters.

Depending on which deployment provider and database/driver you use, there may be special considerations. Please take a look at the deployment docs for your respective scenario to make sure you can deploy your application successfully:

If you want to deploy an app using Turso, you can follow the instructions in Using driver adapters.

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu