19 · Integrations
Prisma on Cloudflare — or skip it
Use Prisma's edge client, or skip the dep entirely with forge/data. Same connection pooling, query builder, migrations — built in.
Code
prisma.js
class="tk-cm">// With forge/data (recommended — zero deps) import { WebApp } from class="tk-str">39;@hyperbridge/forge/server39;; import { Pool, Model } from class="tk-str">39;@hyperbridge/forge/data39;; const app = new WebApp(); const User = new Model(class="tk-str">39;users39;, { id: class="tk-str">39;serial39;, email: class="tk-str">39;text39;, name: class="tk-str">39;text39;, }); app.get(class="tk-str">39;/users39;, async (c) => { const pool = new Pool({ url: c.env.DATABASE_URL }); return c.json(await User.findAll(pool)); }); export default app; class="tk-cm">// ── Or with Prisma: class="tk-cm">// class="tk-cm">// import { PrismaClient } from class="tk-str">39;@prisma/client/edge39;; class="tk-cm">// app.get(class="tk-str">39;/users39;, async (c) => { class="tk-cm">// const db = new PrismaClient({ datasourceUrl: c.env.DATABASE_URL }); class="tk-cm">// return c.json(await db.user.findMany()); class="tk-cm">// });
How it works
forge/data covers ~80% of Prisma's surface (Pool, Model, Migration, transactions, query builder) without the codegen step, without the dependency.
On Cloudflare, Prisma's edge client connects via HTTP through Prisma Data Proxy. forge/data connects to whatever URL you give it — including D1, Hyperdrive, Neon, PlanetScale.
Migrations live next to your code as plain SQL files. Migration.run(pool, dir) applies them in order, tracks state in a table.
Try it
Quickstart
wrangler dev → curl http://localhost:8787/users
Related modules
This is HBForge's port of Hono's example. Read the original at hono.dev/examples/prisma.