Prisma Client generation
Generate a typed database client for application code from the Prisma data model.
Prisma · Const
generator is a Prisma schema block that configures assets produced by prisma generate. For the current Prisma Client generator, set provider and the required output path.
In a Prisma schema, generator introduces a named generator block. The block selects the generator with provider and, for the current prisma-client generator, specifies the required destination with output; running prisma generate then creates the configured assets there.
generator <name> {
provider = "<generator-provider>"
output = "<output-path>"
}| Name | Type | Description |
|---|---|---|
provider | string | Selects the generator implementation, such as the built-in Prisma Client generator. |
output | string | Required for prisma-client; path where generated Prisma Client code is written. |
Generated assets, including customized Prisma Client code when the prisma-client provider is configured.
prisma generate executes.prisma-client, output is mandatory and identifies the generated client's destination.prisma-client provider produces a database-specific Prisma Client for application code.prisma-client generator, omitting output is invalid because the generated client destination must be explicit.generator client {
provider = "prisma-client"
output = "./generated"
}
This schema block configures Prisma Client generation; run npx prisma generate from the project to create the client in the selected output directory.
Generate a typed database client for application code from the Prisma data model.
Create outputs from more than one configured generator in a single schema.
Keep generated client code in a project-controlled directory by setting an explicit destination.
A generator block defines which assets Prisma creates when prisma generate runs. Its name is an identifier for the block, while provider selects the generator implementation.
Follow-up: How do you control where the generated client is written? Set the required output field to a path in the generator block.
The current Prisma Client generator uses provider = "prisma-client". It also requires an output path, which determines where the generated Prisma Client code is placed.
Follow-up: What happens after configuration? Running prisma generate reads the schema and generates the customized client in that output directory.
A schema can contain one or more generators, and each generator determines assets produced by prisma generate. The command processes the generators defined in the schema.
Follow-up: How can a project use more than one generator? Add multiple named generator blocks, each configured for its own provider and supported options.
prisma-clientprisma-client-jsprisma generateprovideroutputdatasourcedata model