P
Prisma2w ago
Donda

Prisma Singleton issue

I have a type issue I cant figure out why is happening .. im using the latest prisma v7.. Path: prisma/schema.prisma schema.prisma: generator client { provider = "prisma-client" output = "./generated/prisma" } Path: prisma.config.ts (project root level) import 'dotenv/config' import type { PrismaConfig } from "prisma"; import { env } from "prisma/config"; export default { schema: "prisma/schema.prisma", migrations: { path: "prisma/migrations", seed: 'tsx prisma/seed-apps.ts', }, datasource: { url: env("DIRECT_URL"), //DATABASE_URL: pooled , DIRECT_URL: direct Connection to the DB for Migrations } } satisfies PrismaConfig; Now the issue I have is this : Expected 1 arguments, but got 0.ts(2554) class.ts(73, 5): An argument for 'options' was not provided. ⚠ Error (TS2554) | Expected 1 arguments, but got 0. on this file : // lib/prisma.ts: import { PrismaClient } from "@/prisma/generated/prisma/client" const globalForPrisma = globalThis as unknown as { prisma: PrismaClient } export const prisma = globalForPrisma.prisma || new PrismaClient() if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma here is the prisma folder tree: ├─ prisma │ ├─ generated │ │ └─ prisma │ │ ├─ browser.ts │ │ ├─ client.ts │ │ ├─ commonInputTypes.ts │ │ ├─ enums.ts │ │ ├─ internal │ │ │ ├─ class.ts │ │ │ ├─ prismaNamespace.ts │ │ │ └─ prismaNamespaceBrowser.ts │ │ ├─ models │ │ └─ models.ts │ ├─ migrations │ │ ├─ 20251120140006_added_analytics_for_projects │ │ │ └─ migration.sql │ │ └─ migration_lock.toml │ ├─ schema.prisma │ └─ seed-apps.ts ├─ prisma.config.ts
8 Replies
Prisma AI Help
Skipping coffee for instant knowledge! Let's brew that AI answer now. The error comes from a change in the generated PrismaClient constructor types in recent Prisma versions: the generated PrismaClient now has a generic constructor signature that expects an options argument, so new PrismaClient() without arguments no longer type-checks unless defaults are provided. This was reported when extending PrismaClient and required passing generics or changing the generated constructor signature. [Prisma 6.14 extend] You’re using the new prisma-client generator with a custom output and importing from that path, which is correct:
generator client {
provider = "prisma-client"
output = "./generated/prisma"
}
generator client {
provider = "prisma-client"
output = "./generated/prisma"
}
and:
import { PrismaClient } from "@/prisma/generated/prisma/client"
import { PrismaClient } from "@/prisma/generated/prisma/client"
That matches the docs for the new generator. [prisma-client getting started] The problem is specifically new PrismaClient() in your singleton:
export const prisma = globalForPrisma.prisma || new PrismaClient()
export const prisma = globalForPrisma.prisma || new PrismaClient()
Because of the updated constructor typing, TypeScript expects an options argument. Workarounds visible in the knowledge: 1. Pass an options object (even empty, but typically with your config):
export const prisma =
globalForPrisma.prisma ??
new PrismaClient({
// e.g. log: ['error', 'warn'] as const,
})
export const prisma =
globalForPrisma.prisma ??
new PrismaClient({
// e.g. log: ['error', 'warn'] as const,
})
This satisfies the constructor signature. If you’re using Prisma.PrismaClientOptions, make sure log and other fields are correctly typed, e.g.:
import type { Prisma } from "@/prisma/generated/prisma/client"

const options: Prisma.PrismaClientOptions = {
log: ['error', 'warn'],
}

export const prisma =
globalForPrisma.prisma ?? new PrismaClient(options)
import type { Prisma } from "@/prisma/generated/prisma/client"

const options: Prisma.PrismaClientOptions = {
log: ['error', 'warn'],
}

export const prisma =
globalForPrisma.prisma ?? new PrismaClient(options)
(Using a properly typed options object is how a similar type error around log was fixed. [Multiple clients options]) 2. If you extend PrismaClient or hit constructor generics you might need to specify the generic parameters explicitly, as in the reported workaround: [Prisma 6.14 extend]
// Example pattern when extending, shown in issue:
class PrismaService extends PrismaClient<Prisma.PrismaClientOptions, any> {}
// Example pattern when extending, shown in issue:
class PrismaService extends PrismaClient<Prisma.PrismaClientOptions, any> {}
But for a plain singleton like yours, simply passing an options object is enough; you don’t need to touch generics. Your updated lib/prisma.ts would be:
import { PrismaClient } from "@/prisma/generated/prisma/client"

const globalForPrisma = globalThis as unknown as { prisma?: PrismaClient }

const prisma =
globalForPrisma.prisma ??
new PrismaClient({
// optional: log: ['error', 'warn'],
})

if (process.env.NODE_ENV !== "production") {
globalForPrisma.prisma = prisma
}

export { prisma }
import { PrismaClient } from "@/prisma/generated/prisma/client"

const globalForPrisma = globalThis as unknown as { prisma?: PrismaClient }

const prisma =
globalForPrisma.prisma ??
new PrismaClient({
// optional: log: ['error', 'warn'],
})

if (process.env.NODE_ENV !== "production") {
globalForPrisma.prisma = prisma
}

export { prisma }
If this still errors, the remaining typing details (constructor generics) aren’t fully documented in the provided sources; in that case, I’m afraid the knowledge we have doesn’t show an official v7-specific pattern beyond the general workarounds above. 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Donda
DondaOP2w ago
the version im using is Prisma v7 on a nextjs 15.5.0 version
Nurul
Nurul2w ago
Hey @Donda! You need to pass adapter to prisma client which doesn't seem to be doing.
Donda
DondaOP2w ago
thanks i was able to fix this issue.
Reen Reen
Reen Reen2w ago
hye guys i just upgraded to prisma 7 folllow its documentation, using mysql im stuck at connection pooling time, my db password has special character, and already strigify, what im missing here
Donda
DondaOP6d ago
@Reen Reen have you fixed it ?
Reen Reen
Reen Reen6d ago
still cannot

Did you find this page helpful?