Getting started
Learn how to quickly set up and start using Prisma Optimize
Prerequisites
Before you begin with Prisma Optimize, ensure you have:
- A Prisma Data Platform account
- A project using Prisma Client
- A PostgreSQL, MySQL/MariaDB, CockroachDB, or MS SQL Server database
Prisma Optimize is intended for use in local development environments. Learn more in the FAQ.
1. Launch Optimize
- Log in to your Prisma Data Platform account
- Click the Optimize tab in the left navigation
- Click Generate API key
- Copy the API key and save it securely
- Click through the setup screens until you see Finish & optimize
2. Add Optimize to your application
Install the extension
npm install @prisma/extension-optimizeAdd API key to .env
OPTIMIZE_API_KEY="YOUR_OPTIMIZE_API_KEY"Extend Prisma Client
import { PrismaClient } from "@prisma/client";
import { withOptimize } from "@prisma/extension-optimize";
const prisma = new PrismaClient().$extends(
withOptimize({ apiKey: process.env.OPTIMIZE_API_KEY })
);Using with other extensions:
Extensions are applied sequentially. If using Prisma Accelerate, apply it after Optimize:
const prisma = new PrismaClient()
.$extends(withOptimize())
.$extends(withAccelerate());3. Generate insights
- In the Optimize dashboard, click Start recording
- Run your app and execute Prisma queries
- Click Stop recording when done
- Explore query details and check the Recommendations tab
Use Prisma AI to understand recommendations and apply them within your Prisma model context.
Next steps
- Recommendations - Learn about performance recommendations
- Recordings - Understand recording sessions
- Examples - Try a hands-on example
Need help?
Reach out in the #help-and-questions channel on Discord, or connect with our community.