Prisma Schema with Neon Project Per User
Hi all,
I am currently investigating a project per user set up for my multi-tenant application which uses Neon, Prisma ORM and Next.js hosted in Vercel.
I have played around with the Neon API and was able to create a new project and run migrations on that project as soon as a new user logs in to the application.
All good so far.
However, I realised one issue at the point where requests are made to my database via Prisma. That is, usually the Prisma Client is only instantiated once and database url is defined once with:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
This is a problem as I will have many DATABASE_URL variables with this set up.
I think creating new Prisma Client instances for each request is a bad idea.
Any advice to get around this?
Maybe this is the wrong direction, but Neon makes it so easy and cheap to have a database per user and I would like to pursue it if possible, not least because my particular type of user values data security a lot (more of a peace of mind thing).0 Replies