Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Ankur Datta <[email protected]>
  • Loading branch information
jharrell and ankur-arch authored Jan 1, 2025
1 parent 79e3e7a commit 96fdaa5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ Usually, this works transparently, but some connection poolers only support a li

:::info

Looking for an easy and infrastructure-free option? Try [Prisma Accelerate](https://www.prisma.io/accelerate?utm_source=docs&utm_campaign=pgbouncer-help)! Little to no setup and is compatible with all databases that Prisma ORM supports.

Get started with Prisma Accelerate [here](https://console.prisma.io?utm_source=docs&utm_campaign=pgbouncer-help).
Looking for an easy, infrastructure-free solution? Try [Prisma Accelerate](https://www.prisma.io/accelerate?utm_source=docs&utm_campaign=pgbouncer-help)! It requires little to no setup and works seamlessly with all databases supported by Prisma ORM.

Ready to begin? Get started with Prisma Accelerate by clicking [here](https://console.prisma.io?utm_source=docs&utm_campaign=pgbouncer-help).
:::

## PgBouncer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ Prisma ORM and Next.js form a powerful combination for building modern, server-s

---

## Best Practices for Using Prisma Client in Development
## Best practices for using Prisma Client in development

### Avoid Multiple Prisma Client Instances
### Avoid multiple Prisma Client instances

When developing a Next.js application, one common issue is accidentally creating multiple instances of the Prisma Client. This often occurs due to Next.js’s hot-reloading feature in development.

#### Why This Happens
#### Why this happens

Next.js’s hot-reloading feature reloads modules frequently to reflect code changes instantly. However, this can lead to multiple instances of Prisma Client being created, which consumes resources and might cause unexpected behavior.

#### Recommended Solution
#### Recommended solution

To avoid this, create a single Prisma Client instance by using a global variable:

Expand All @@ -47,16 +47,16 @@ Using this approach ensures that only one instance of Prisma Client exists, even

## Setting Up Prisma ORM in a Monorepo

### Challenges of Using Prisma ORM in Monorepos
### Challenges of using Prisma ORM in monorepos

Monorepos allow multiple projects to share code and dependencies, making them a popular choice for modern development. However, using Prisma ORM in a monorepo can present challenges related to dependency resolution and schema management.

#### Key Issues
#### Key issues

1. **Dependency Resolution**: Multiple packages in a monorepo might lead to conflicts if they use different version of Prisma ORM.
2. **Schema Centralization**: Managing a single Prisma Schema across multiple projects can be complex.

#### Best Practices for Monorepo Integration
#### Best practices for monorepo integration

- **Centralize the Prisma Schema**: Place the `schema.prisma` file in a shared package, such as `@myorg/db`, to ensure consistency.
- **Install Dependencies in the Root**: Avoid version conflicts by installing Prisma ORM as a dependency at the root of the monorepo.
Expand All @@ -74,9 +74,9 @@ This approach keeps your Prisma Schema and generated client in sync across all p

---

## Dynamic Usage of Prisma Client in Next.js
## Dynamic usage of Prisma Client in Next.js

### Handling Dynamic Scenarios
### Handling dynamic scenarios

Dynamic use cases, such as working with tenant-specific databases, require additional consideration when using Prisma ORM with Next.js.

Expand Down

0 comments on commit 96fdaa5

Please sign in to comment.