Next.js Discord

Discord Forum

Using Prisma in Middleware

Unanswered
Marchy posted this in #help-forum
Open in Discord
I'm trying to use Prisma within middleware to do a token check for a basic auth example, however I'm getting this error:
Error: PrismaClient is unable to be run in the browser.

I was expecting to be able to access the database within middleware, but would I just need to move that portion out to a route handler?

3 Replies

Giant panda
Middleware always runs on Edge. Prisma isn’t supported there.
Chub mackerel
there's prisma/client/edge package you can use