First of all, I am using Prisma (with Lucia adapter) and Next.js 14.
So, when I try to call the following function in middleware.ts, it returns the error: Error: PrismaClient is unable to run in Vercel Edge Functions or Edge Middleware. As an alternative, try Accelerate: https://pris.ly/d/accelerate. (screenshot provided below).
I think this is because you shouldn't use the PrismaClient in middleware, rather to use PrismaClient from @prisma/client/edge. Check this issue for more details: https://github.com/prisma/prisma/issues/21310
Package
lucia
Describe the bug
Hello,
First of all, I am using Prisma (with Lucia adapter) and Next.js 14.
So, when I try to call the following function in
middleware.ts
, it returns the error: Error: PrismaClient is unable to run in Vercel Edge Functions or Edge Middleware. As an alternative, try Accelerate: https://pris.ly/d/accelerate. (screenshot provided below).I think this is because you shouldn't use the PrismaClient in middleware, rather to use PrismaClient from @prisma/client/edge. Check this issue for more details: https://github.com/prisma/prisma/issues/21310