Skip to content

Commit

Permalink
Update 090-nextjs.mdx
Browse files Browse the repository at this point in the history
  • Loading branch information
Levix0501 authored Mar 5, 2025
1 parent ac69b71 commit ac01fe3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions content/800-guides/090-nextjs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ Now, add the following code to your `lib/prisma.ts` file:
import { PrismaClient } from '@prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'

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

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
Expand All @@ -284,11 +284,11 @@ This file creates a Prisma Client and attaches it to the global object so that o

If you're not using Prisma Postgres, replace the line
```ts
const prisma = new PrismaClient().$extends(withAccelerate())
const prisma = globalForPrisma.prisma || new PrismaClient().$extends(withAccelerate())
```
with
```ts
const prisma = new PrismaClient()
const prisma = globalForPrisma.prisma || new PrismaClient()
```
and remove the `@prisma/extension-accelerate` import.

Expand Down Expand Up @@ -740,4 +740,4 @@ For more information and updates:
- [Prisma Client API reference](/orm/prisma-client)
- [Next.js documentation](https://nextjs.org/docs)
- Join our [Discord community](https://discord.com/invite/prisma)
- Follow us on [Twitter](https://twitter.com/prisma)
- Follow us on [Twitter](https://twitter.com/prisma)

0 comments on commit ac01fe3

Please sign in to comment.