Hey all! I’m getting this behavior when trying to ...
# prisma-client
g
Hey all! I’m getting this behavior when trying to query prisma in a
next.js
middleware page. Has anyone encountered this before?
👀 1
n
You are trying to run the prisma client on the client (browser) side. This is not possible. Prisma runs on the server. This code should be under api/ for a NextJs project.
plus one +1 1
g
@Necmettin Begiter Doesn’t middleware run on the server though?
n
As far as I can remember (I don’t use NextJs daily), everything under pages (except api) runs on both server and client. But I’m not an expert on NextJs.
j
Indeed you can use Prisma only on the server side so these are the options: getStaticProps = Static Site Generation getServerSideProps = Server-Side Rendering API Routes Standalone Server See examples at https://www.prisma.io/nextjs