HBForge/Examples
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.

forge/serverforge/dataCF Workers
Code
prisma.js
class="tk-cm">// With forge/data (recommended — zero deps)
import { WebApp }         from class="tk-str">'@hyperbridge/forge/server';
import { Pool, Model }    from class="tk-str">'@hyperbridge/forge/data';

const app  = new WebApp();
const User = new Model(class="tk-str">'users', {
  id: class="tk-str">'serial', email: class="tk-str">'text', name: class="tk-str">'text',
});

app.get(class="tk-str">'/users', 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">'@prisma/client/edge';
class="tk-cm">// app.get(class="tk-str">'/users', 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