diff --git a/content/300-accelerate/200-getting-started.mdx b/content/300-accelerate/200-getting-started.mdx index b976a14389..4904e1525e 100644 --- a/content/300-accelerate/200-getting-started.mdx +++ b/content/300-accelerate/200-getting-started.mdx @@ -102,13 +102,9 @@ When using Prisma Accelerate in a Serverless or an Edge application, we recommen npx prisma generate --no-engine ``` - - The `--no-engine` flag prevents a Query Engine file from being included in the generated Prisma Client, this ensures the bundle size of your application remains small. - - - +:::warning If your Prisma version is below `5.2.0`, generate Prisma Client with the `--accelerate` option: @@ -118,7 +114,11 @@ npx prisma generate --accelerate If your Prisma version is below `5.0.0`, generate Prisma Client with the `--data-proxy` option: - +```terminal +npx prisma generate --data-proxy +``` + +::: ### 2.4. Extend your Prisma Client instance with the Accelerate extension @@ -142,7 +142,15 @@ const prisma = new PrismaClient().$extends(withAccelerate()) If VS Code does not recognize the `$extends` method, refer to [this section](/accelerate/faq#vs-code-does-not-recognize-the-extends-method) on how to resolve the issue. - +#### Using the Accelerate extension with other extensions or middleware + +Since [extensions are applied one after another](/orm/prisma-client/client-extensions#conflicts-in-combined-extensions), make sure you apply them in the correct order. Extensions cannot share behavior and the last extension applied takes precedence. + +If you are using [Prisma Optimize](/optimize) in your application, make sure you apply it _before_ the Accelerate extension. For example: + +```ts +const prisma = new PrismaClient().$extends(withOptimize()).$extends(withAccelerate()) +``` If you are using [Prisma Middleware](/orm/prisma-client/client-extensions/middleware) in your application, make sure they are added before any Prisma Client extensions (like Accelerate). For example: @@ -150,8 +158,6 @@ If you are using [Prisma Middleware](/orm/prisma-client/client-extensions/middle const prisma = new PrismaClient().$use(middleware).$extends(withAccelerate()) ``` - - ### 2.5. Use Accelerate in your database queries The `withAccelerate` extension primarily does two things: diff --git a/content/700-optimize/200-getting-started.mdx b/content/700-optimize/200-getting-started.mdx index 57ee6331e1..4ed7412029 100644 --- a/content/700-optimize/200-getting-started.mdx +++ b/content/700-optimize/200-getting-started.mdx @@ -73,6 +73,22 @@ const prisma = new PrismaClient().$extends( ); ``` +#### Using the Optimize extension with other extensions or middleware + +Since [extensions are applied one after another](/orm/prisma-client/client-extensions#conflicts-in-combined-extensions), make sure you apply them in the correct order. Extensions cannot share behavior and the last extension applied takes precedence. + +If you are using [Prisma Accelerate](/accelerate) in your application, make sure you apply it _after_ the Optimize extension. For example: + +```ts +const prisma = new PrismaClient().$extends(withOptimize()).$extends(withAccelerate()) +``` + +If you are using [Prisma Middleware](/orm/prisma-client/client-extensions/middleware) in your application, make sure they are added before any Prisma Client extensions (like Optimize). For example: + +```ts +const prisma = new PrismaClient().$use(middleware).$extends(withOptimize()) +``` + ### 2.5. Use Prisma Optimize to generate insights Follow these steps to start generating query insights with Prisma Optimize: