From bca3f13a929fa0cf7b36b454bda6dbf761a989fa Mon Sep 17 00:00:00 2001 From: Nurul Sundarani Date: Fri, 10 Jan 2025 17:29:48 +0530 Subject: [PATCH] Add example snippet to enable Optimizie only in development (#6581) --- content/700-optimize/600-faq.mdx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/content/700-optimize/600-faq.mdx b/content/700-optimize/600-faq.mdx index c2e97c8d90..96f3af983c 100644 --- a/content/700-optimize/600-faq.mdx +++ b/content/700-optimize/600-faq.mdx @@ -28,4 +28,18 @@ They are counted based on viewed recommendations. Once you click on a recommenda ## Can I use Prisma Optimize in production? -No, Prisma Optimize is not intended for production use. It is specifically designed for local development, providing valuable insights and optimizations during that phase. While it’s technically possible to run it in a production environment, doing so could result in performance problems or unexpected behaviors, as Optimize is not built to handle the complexity and scale of production workloads. For the best experience, we recommend using Prisma Optimize solely in your development environment. \ No newline at end of file +No, Prisma Optimize is not intended for production use. It is specifically designed for local development, providing valuable insights and optimizations during that phase. While it’s technically possible to run it in a production environment, doing so could result in performance problems or unexpected behaviors, as Optimize is not built to handle the complexity and scale of production workloads. For the best experience, we recommend using Prisma Optimize solely in your development environment. + +You can use the `enable` property in the Optimize extension to run Optimize only in development envrioment. By default, the `enable` property is set to `true`. + +```ts file=script.ts copy showLineNumbers +import { PrismaClient } from '@prisma/client' +import { withOptimize } from "@prisma/extension-optimize" + +const prisma = new PrismaClient().$extends( + withOptimize({ + apiKey: process.env.OPTIMIZE_API_KEY, + enable: process.env.ENVIRONMENT === 'development', + }) +); +``` \ No newline at end of file