Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

prisma-data-proxy-alt

> 编程语言
Open source

This is a library to alternate and self-host the Prisma Data Proxy (cloud.prisma.io)

198 stars0 likes0 views
WebsiteGitHub

About

This is a library to alternate and self-host the Prisma Data Proxy (cloud.prisma.io)

Alternative Prisma Data Proxy

This is a library to alternate and self-host the Prisma Data Proxy (cloud.prisma.io).

In order to deploy your project to edge runtimes (such as Cloudflare Workers or Vercel Edge Functions) and use Prisma, you will need to use the Prisma Data Proxy.
However, at present, instances can only be built in limited areas, and there are also delays caused by cold standby. This is a very stressful problem.

Therefore, we have created a server library to replace Prisma Data Proxy. With it, you are free from stressful limitations. You can deploy it on any platform in any region you like and use any data source you like, such as Supabase or Planetscale.

No changes are required to your prisma client code, just set the DATABASE_URL to the URL you self-hosted with this library.
This is not an official library, but it works the same as Prisma Data Proxy.

Overview

Performance

Using the Alternative Prisma Data Proxy, a significant reduction in clause latency can be expected regardless of the region of the instance. See here for details.

Setup

If you are using @prsima/client v3, install prisma-data-proxy-alt@^1.
The latest library (v2) suports only @prima/client v4.

bash
yarn add prisma-data-proxy-alt

Include prisma schema in your project. The same schema as the client.

bash
cp your_client_project_path/prisma/schema.prisma ./prisma/schema.prisma

Install prisma and @prisma/client.

bash
yarn add -D prisma
yarn add @prisma/client

Launch proxy server

Give environment variables by creating .env, etc.

PRISMA_SCHEMA_PATH=/absolute/path/for/your/schema.prisma
DATABASE_URL={database URL scheme e.g. postgresql://postgres:pass@db:5432/postgres?schema=public}
DATA_PROXY_API_KEY={random string for authentication}
PORT={server port e.g. 3000}
bash
yarn pdp

This will bring up the proxy server, but it must be SSL-enabled to connect from @prisma/client.
So here are the steps to establish a local connection with SSL using docker-compose and https-portal with a self certificate.

Create entrypoint.sh.

bash
#!/bin/sh

yarn install
exec "$@"

Create docker-compose.yml.

…
bash
docker-compose up

Now you can connect with data proxy with DATABASE_URL=prisma://localhost?api_key={DATA_PROXY_API_KEY}.

Deploy

GCP Cloud Run

Create Dockerfile

dockerfile
FROM node:16.15-bullseye-slim as base

RUN apt-get update && apt-get install -y tini ca-certificates \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/*

WORKDIR /app

FROM base as builder

COPY package.json .
COPY yarn.lock .
COPY prisma/schema.prisma ./prisma/schema.prisma

RUN yarn install

RUN yarn prisma generate

FROM base

COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json

ENV PRISMA_SCHEMA_PATH=/app/node_modules/.prisma/client/schema.prisma

USER node

ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["yarn", "pdp"]

Create cloudbuild.yml

…

Create a new trigger from the GCP Cloud Build web console and link it to your repository.

Set _REGION, _DATABASE_URL, and _DATA_PROXY_API_KEY in the substitution values.

  • _REGION: The region of deploy target for Cloud Run
  • _DATABASE_URL: Connection URL to your data source (mysql, postgres, etc...)
  • _DATA_PROXY_API_KEY: Arbitrary string to be used when connecting data proxy. e.g. prisma://your.deployed.domain?api_key={DATA_PROXY_API_KEY}
    (do not divulge it to outside parties)

For Client (on your application)

On the client side, generate the Prisma client in data proxy mode --data-proxy. official document

bash
yarn prisma generate --data-proxy

Set the DATABSE_URL from the domain of the server you deployed and the api key (DATA_PROXY_API_KEY) you set for it.

DATABSE_URL=prisma://${YOUR_DEPLOYED_PROJECT_DOMAIN}?api_key=${DATA_PROXY_API_KEY}

**Now you can connect to the (alternative) Data Proxy from your application. **

Contribution

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

LICENCE

This project is licensed under the MIT License - see the LICENSE file for details

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言