Skip to main content
Prisma Documentation Docs
current

Search documentation

Type to search this documentation.

On this pageOverview

Generating Prisma Client (Prisma ORM v7)

Learn when and how to run prisma generate, configure the generator output, and import the generated client in your app.

prisma generate creates Prisma Client from the models and generator configuration in your schema.prisma file.

In Prisma ORM v7, the output field is required:

schema.prisma
generator client {
  provider = "prisma-client"
  output   = "./generated"
}

Run the following command whenever you add models, change fields, or update generator settings:

bun
bunx prisma generate
pnpm
pnpm prisma generate
yarn
yarn prisma generate
npm
npx prisma generate

If you want the CLI-specific options such as --watch or --generator, see the prisma generate command reference.

Import Prisma Client from the output path you configured:

TypeScript
import { PrismaClient } from "./generated/client";

const prisma = new PrismaClient();

You should run prisma generate after:

  • changing your Prisma schema
  • updating generator configuration
  • enabling features that affect the client API
  • pulling schema changes from another branch or teammate

In many projects it also makes sense to run prisma generate in postinstall or before your production build so deployments always use a current client.

  • Configuring error formatting: This page explains how to configure the formatting of errors when using Prisma Client
  • Custom model and field names: Learn how you can decouple the naming of Prisma models from database tables to improve the ergonomics of the generated Prisma Client API
  • Database connections: Learn how to manage database connections and configure connection pools
  • Database polyfills: Prisma Client provides features that are not achievable with relational databases. These features are referred to as "polyfills" and explained on this page.
  • Introduction to Prisma Client: Learn how to set up and configure Prisma Client in your project
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu