diff --git a/content/800-data-platform/100-accelerate/580-local-development.mdx b/content/800-data-platform/100-accelerate/580-local-development.mdx index cf14ff0fe8..66af96d76d 100644 --- a/content/800-data-platform/100-accelerate/580-local-development.mdx +++ b/content/800-data-platform/100-accelerate/580-local-development.mdx @@ -10,21 +10,20 @@ toc: true Prisma Accelerate is designed to efficiently scale database connections in a production environment while providing a global cache. To leverage the benefits of connection pooling and a global cache, it is essential to utilize a publicly accessible database. -In development environments, using a publicly available database may not be possible, and you may want to use a local database. Here, we will explain how to use Prisma Accelerate client extension in a development environment with a local database. +In development environments, you may want to use a local database to minimize expenses. - - -## Prisma Accelerate with a local database +Furthermore, you may consider extending `PrismaClient` with the Accelerate client extension once, so that you can use a local database in development and a hosted database with Accelerate’s connection pooling and caching enabled. This eliminates the need for conditional logic to switch clients between development and production. -To benefit from Accelerate's connection pool and global cache features, you must have a publicly accessible database, enabling the creation of a Prisma Accelerate URL. It's important to note that Accelerate's features won't function with a local database. +Here, we will explain how to use Prisma Accelerate client extension in a development environment with a local database. - + -However, using a local database URL, you can add the Accelerate client extension to your Prisma Client. This will allow you to use a local database in your development environment. Keep in mind that, in this scenario, caching and connection pooling won't be available. +## Using Prisma Accelerate client extension in development and production - +
+ -In a production environment, when a generated Accelerate connection string is used, you will be able to use connection pooling and caching by adding the Accelerate client extension to the `PrismaClient`. +Accelerate doesn’t work with a local database. However, using a local database URL, you can add the Accelerate client extension to your Prisma Client. This will allow you to use a local database in your development environment. Keep in mind that, in this scenario, caching and connection pooling won't be available. Here is how to use a local PostgreSQL database with Prisma ORM and Prisma Accelerate client extension (without caching and connection pooling): @@ -51,16 +50,18 @@ Here is how to use a local PostgreSQL database with Prisma ORM and Prisma Accele const prisma = new PrismaClient().$extends(withAccelerate()) ``` - > `PrismaClient` infers that a local database is being used from the database connection string and disables the connection pooling and caching functionalities of Prisma Accelerate. + > `PrismaClient` with the Accelerate client extension uses the local database connection. Accelerate won’t work as a local database is being used. -## Using Prisma Accelerate in edge functions in a development environment + + +In a production environment, when a generated Accelerate connection string is used, you will be able to use connection pooling and caching by adding the Accelerate client extension to the `PrismaClient`. -When working with Prisma Accelerate in a dev environment for [Next.js edge functions](https://vercel.com/docs/functions/edge-functions), you must use a `PrismaClient` without an engine. +## Locally using Prisma Accelerate in edge functions -To create this engineless PrismaClient, run the command `prisma generate --no-engine`. Now, you will be able to use `PrismaClient` for the edge. +When working with Prisma Accelerate in a dev environment for [Next.js edge functions](https://vercel.com/docs/functions/edge-functions), you must use `PrismaClient` that can be used in edge functions. ```bash import { PrismaClient } from "@prisma/client/edge"; ``` -You must use the Accelerate connection string to use `PrismaClient` for the edge with Accelerate. +The `PrismaClient` in Next.js edge functions does not support a direct database connection, hence you have to use the Accelerate connection string.