prisma: (Accelerate) gives me an error: `PrismaClient is not configured to run in Cloudflare Workers. In order to run Prisma Client on edge runtime`

Bug description

i try to use prisma for postgres and i used prisma accelearate .I configure everything correctly but stills give me an error: PrismaClient is not configured to run in Cloudflare Workers. In order to run Prisma Client on edge runtime

my code

import { Hono } from 'hono'
import{PrismaClient} from "@prisma/client"
import {withAccelerate} from "@prisma/extension-accelerate"
import {sign,verify} from "hono/jwt"

const app = new Hono<{

Bindings:{
  DATABASEURL:string
  JWT_SECRET:string
}
}>()



app.post('/api/v1/signup', async(c) => {
  const prisma=new PrismaClient({
    //@ts-ignore
    datasourceUrl:c.env.DATABASE_URL,
  }).$extends(withAccelerate())
  const body=await c.req.json()
 const user= await prisma.user.create({
    data:{
email:body.email,
password:body.password
    }
    
  })
 

  const token=await sign({id:user.id},c.env.JWT_SECRET)
  return c.json({token})
})

How to reproduce

Expected behavior

No response

Prisma information

// Add your schema.prisma
// Add your code using Prisma Client

Environment & setup

  • OS:
  • Database:
  • Node.js version:

Prisma Version


About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 27 (8 by maintainers)

Most upvoted comments

Hey, I noticed you’re importing the PrismaClient from @prisma/client instead of @prisma/client/edge, you should be using the edge import if you’re deploying to Cloudflare Workers. This should make things work!

You can find this in their documentation: https://www.prisma.io/docs/accelerate/getting-started#24-extend-your-prisma-client-instance-with-the-accelerate-extension

I was facing the same issue, got solved by importing @prisma/client/edge instead of @prisma/client, thanks @AbrahamX3 !!!

I get same error in hono

it worked thank you so much for the solution @AbrahamX3 🤗👍

@iflamed If you are using D1, then you are not using Prisma Accelerate, which this issue is about - you are in the wrong place. Please open a new issue and describe your problem, then we can try to help. Thanks.