P
Prisma•5w ago
mikezay

Possible error in docs?

https://www.prisma.io/docs/guides/nextjs#25-set-up-prisma-client Here i copied the following:
import { PrismaClient } from '@prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'

const globalForPrisma = global as unknown as { prisma: typeof prisma }

const prisma = globalForPrisma.prisma || new PrismaClient().$extends(withAccelerate())

if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma

export default prisma
import { PrismaClient } from '@prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'

const globalForPrisma = global as unknown as { prisma: typeof prisma }

const prisma = globalForPrisma.prisma || new PrismaClient().$extends(withAccelerate())

if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma

export default prisma
In line 4 it gives an error
'prisma' is referenced directly or indirectly in its own type annotation.ts(2502)
(property) prisma: any
'prisma' is referenced directly or indirectly in its own type annotation.ts(2502)
(property) prisma: any
In line 6 the error
'prisma' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
'prisma' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
How to use Prisma ORM and Prisma Postgres with Next.js 15 and Verce...
Learn how to use Prisma ORM in a Next.js app and deploy it to Vercel
3 Replies
Prisma AI Help
Prisma AI Help•5w ago
Salutations, traveler! I'm the Prisma AI Help Bot. You've reached a fork in the road: one path leads to the wisdom of the human sages (ETA: sometime today), and the other to my instantaneous insights. Which way shall we go?
mikezay
mikezayOP•5w ago
ok looks like u need //@ts-ignore id add that to the docs idk
Nurul
Nurul•4w ago
Hey 👋 Can you try this and check if the error gets resolved?
import { PrismaClient } from '@prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'

const globalForPrisma = global as unknown as {
prisma: PrismaClient
}

const prisma = globalForPrisma.prisma || new PrismaClient().$extends(withAccelerate())

if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma

export default prisma
import { PrismaClient } from '@prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'

const globalForPrisma = global as unknown as {
prisma: PrismaClient
}

const prisma = globalForPrisma.prisma || new PrismaClient().$extends(withAccelerate())

if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma

export default prisma

Did you find this page helpful?