Error: PrismaClient is unable to be run in the browser.
I'm trying to create a build file for my next app but I'm getting the error: Error: PrismaClient is unable to be run in the browser.
It says the error is in my /addsubtopics route which is this:
I also tried checking to see if I was trying to run PrismaClient in a client component but these are the only places where I use prisma client (attached screenshot)
Anyone know how I can fix this?
8 Replies
/Users/user/Code/project/.next/server/app/api/addsubtopics/route.js:11
In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`)},o.validator=()=>e=>e,o.DbNull=i.instances.DbNull,o.JsonNull=i.instances.JsonNull,o.AnyNull=i.instances.AnyNull,o.NullTypes={DbNull:i.classes.DbNull,JsonNull:i.classes.JsonNull,AnyNull:i.classes.AnyNull},t.Prisma.ExamsScalarFieldEnum={id:"id",name:"name",file:"file",subject:"subject",year:"year"},t.Prisma.SortOrder={asc:"asc",desc:"desc"},t.Prisma.SubjectsScalarFieldEnum={id:"id",name:"name"},t.Prisma.SubtopicScalarFieldEnum={id:"id",name:"name",topicId:"topicId"},t.Prisma.TopicScalarFieldEnum={id:"id",name:"name",subjectId:"subjectId"},t.Prisma.TransactionIsolationLevel=s({ReadUncommitted:"ReadUncommitted",ReadCommitted:"ReadCommitted",RepeatableRead:"RepeatableRead",Serializable:"Serializable"}),t.Prisma.UserIdScalarFieldEnum={id:"id",clerkUserId:"clerkUserId"},t.Prisma.ModelName={UserId:"UserId",Exams:"Exams",Subjects:"Subjects",Topic:"Topic",Subtopic:"Subtopic"};class a{constructor(){throw Error(`PrismaClient is unable to be run in the browser.
Error: PrismaClient is unable to be run in the browser.
GitHub
Issues · prisma/prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB - Issues · prisma/prisma
Solution
prisma can't run on the edge
oh, that makes sense
is there any work around to this?
people are trying kylesy and drizzle for that reason
ill have to switch over then, thanks
Shoubhit Dash
Typesafe Database Queries on the Edge
Edge computing is all the rage. Learn how to get typesafe access to data on the edge using Kysely, Prisma and PlanetScale.
check this post
i think i'll switch over to drizzle, i've been wanting to use it
thanks