Repository navigation
docs(examples/prisma): update Prisma setup for Prisma ORM 8 - #922
Open
ankur-arch wants to merge 1 commit into
Open
ankur-arch wants to merge 1 commit into
ankur-arch wants to merge 1 commit into
Conversation
Rewrite the Prisma Postgres section for Prisma ORM 8 (orm init, @prisma/orm-postgres, nodejs_compat, one client per request), pin the D1 section to Prisma ORM 7 with the current generator and CLI flags, add a short Prisma Compute pointer, and fix the resource links.
yusukebe
reviewed
Oct 25, 2026
| Here is an example of how you can use this function in your project: | ||
| app.use(async (c, next) => { | ||
| const db = postgres<Contract>({ | ||
| contractJson, |
Member
There was a problem hiding this comment.
The current postgres options do not accept contractJson and should be contract. The document show fhe following:
const contract = contractFromJson<Contract>(contractJson);
export default {
async fetch(request, env, ctx): Promise<Response> {
const path = new URL(request.url).pathname;
if (path === "/favicon.ico") return new Response("Not found", { status: 404 });
const db = postgres({ contract, url: env.DATABASE_URL });
Member
|
Hey @ankur-arch Thank you for the PR! Nice. I left a comment. Please check it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi Hono team! This updates the Prisma on Cloudflare Workers example, which still showed the Accelerate-based setup that no longer works with current Prisma releases.
What changed
npx prisma@latest orm init, the@prisma/orm-postgrespackage and thenodejs_compatflag. The example is a Hono middleware that creates one client per request and closes it withc.executionCtx.waitUntil, plusGET /usersandPOST /usersroutes. It follows the Prisma docs guide for Cloudflare Workers.prisma@7and@prisma/client@7(plainnpx prismainstalls 8 today). It drops thedriverAdapterspreview flag, switches to theprisma-clientgenerator withruntime = "cloudflare", changes--to-schema-datamodelto--to-schema, fixes the client import path so it matches the generator output, and adds awrangler.jsonctab since the template now creates that file. It follows the Prisma Cloudflare D1 guide.How I tested
I followed the page step by step in fresh
npm create hono@latest(cloudflare-workers) projects with Wrangler 4.151:prisma8.0.0-rc.24,@prisma/orm-postgres8.0.0-rc.18): created a database withnpx create-db, randb init, thenwrangler dev.POST /userscreated rows andGET /usersreturned them across repeated requests.tsc --noEmitandwrangler deploy --dry-runpass.wrangler d1 migrations create,prisma migrate diff --to-schema,wrangler d1 migrations apply --localandprisma generateas written, thenwrangler devreturned the inserted rows fromGET /. Local D1 only, sincewrangler d1 createand--remoteneed a Cloudflare account./api/usersreturned the seeded rows.Deploys to Cloudflare were not run.
One gotcha found while testing is now called out in the page: the Hono template ships a
pnpm-workspace.yaml, soorm initinstalls with pnpm unless the file is removed first.Disclosure: I work at Prisma. Happy to trim the Compute section or change anything else you'd like.