PrismaP
Prisma2mo ago
2 replies
Tvrtko

Confused with documentation related to instantiation of PrismaClient

Everywhere I looked, the suggestion is to instantiate PrismaClient once globally, but when working with
better-auth
I encountered this warning after code snippet on how to do it globally:

We recommend using a connection pooler (like Prisma Accelerate) to manage database connections efficiently.

If you choose not to use one, avoid instantiating PrismaClient globally in long-lived environments. Instead, create and dispose of the client per request to prevent exhausting your database connections.


So, I'm confused. should I instantiate my PrismaClient globally or create and dispose the client for each request (and what's the recommended way for doing this)?
Was this page helpful?