Skip to content

Commit d0a17f2

Browse files
docs: update PrismaClient initialization for v7 mandatory driver adapters (#7804)
* Enhance PrismaClient setup with adapter and requirements Updated PrismaClient initialization to include adapter support and added Prisma 7 connection requirements. * Update apps/docs/content/docs/orm/index.mdx Adding suggestions from coderabbitai, resolving the minor issue. Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update database adapter to use PrismaPg for PostgreSQL --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent f79c148 commit d0a17f2

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

apps/docs/content/docs/orm/index.mdx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,14 @@ npx prisma generate
115115

116116
```ts
117117
import { PrismaClient } from "./generated/client";
118+
// Import the driver adapter for your specific database (example uses PostgreSQL)
119+
import { PrismaPg } from "@prisma/adapter-pg";
118120

119-
const prisma = new PrismaClient();
121+
// Initialize the adapter according to your driver's requirements
122+
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL });
123+
124+
// Pass the adapter instance to PrismaClient
125+
const prisma = new PrismaClient({ adapter });
120126

121127
// Find all users with their posts
122128
const users = await prisma.user.findMany({
@@ -133,6 +139,20 @@ const user = await prisma.user.create({
133139
},
134140
});
135141
```
142+
:::note
143+
144+
### Prisma 7 Connection Requirements
145+
Starting with **Prisma 7**, providing a [driver adapter](/orm/core-concepts/supported-databases/database-drivers) is mandatory for direct database connections. This change standardizes database connectivity across Node.js, Serverless, and Edge environments.
146+
147+
If you use Prisma Accelerate, instantiate Prisma Client with `accelerateUrl` and the Accelerate extension instead of a driver adapter.
148+
149+
To ensure compatibility:
150+
* **Install an adapter:** Use the specific package for your database (e.g., `@prisma/adapter-pg`, `@prisma/adapter-mysql`, etc.).
151+
* **Enable ESM:** Your `package.json` must include `"type": "module"`.
152+
153+
For detailed instructions, see the [V7 Upgrade Guide](/guides/upgrade-prisma-orm/v7).
154+
155+
:::
136156

137157
## Next steps
138158

0 commit comments

Comments
 (0)