Prisma Singleton in Next.js

Hi, I used the Prisma docs (https://www.prisma.io/docs/orm/more/help-and-troubleshooting/help-articles/nextjs-prisma-client-dev-practices) to setup and tested it. In my Next application, I observed the fact that, whenever I navigate between pages, the globalThis is reset, expected one time the Prisma client to be instantiated and used across all the app, but this was not the case. Am I doing something wrong? Does NextJS initiate Prisma on each page? Thank you This is a question I got from one of my students in my new course where I didn't know the definitive answer.
Best practice for instantiating Prisma Client with Next.js | Prisma...
Best practice for instantiating Prisma Client with Next.js
1 Reply
RaphaelEtim
RaphaelEtim3w ago
Hi @rwieruch Thank you for raising this question. The singleton pattern used should prevent this kind of reset from happening under normal circumstances. Using the globalThis is supposed to maintain a single instance of Prisma Client across page navigation. Can you provide more information about your setup? A minimal reproduction would go a long way to help us investigate this.
Want results from more Discord servers?
Add your server