Setting the file. One moment.
Subchapter 1.10
references/generate.mdMarkdown3 KBView on GitHub
Generates assets based on the generator blocks in your Prisma schema, most commonly Prisma Client.
prisma generate [options]If you’re using Bun, run Prisma with bunx --bun so it doesn’t fall back to Node.js:
bunx --bun prisma generateschema.prisma file| Option | Description |
|---|---|
--schema | Custom path to your Prisma schema |
--config | Custom path to your Prisma config file |
--sql | Generate typed sql module |
--watch | Watch the Prisma schema and rerun after a change |
--generator | Generator to use (may be provided multiple times) |
--no-hints | Hides the hint messages but still outputs errors and warnings |
--require-models | Do not allow generating a client without models |
prisma generateprisma generate --watchAuto-regenerates when schema.prisma changes.
prisma generate --generator clientprisma generate --generator client --generator zod_schemasprisma generate --sqlgenerator client {
provider = "prisma-client"
output = "../generated"
}prisma-client is the standard generatoroutput is required when using prisma-clientprisma-client supports both ESM and CommonJS via moduleFormatcompilerBuild supports fast and small query compiler artifactssatisfies for typed query fragments with prisma-clientimport { PrismaClient } from '../generated/prisma/client'Use compilerBuild when you need to trade artifact size against the default build:
generator client {
provider = "prisma-client"
output = "../generated"
compilerBuild = "small"
}fast is the default build for most targetssmall is useful for size-constrained targetsvercel-edge targets to smallprisma migrate dev --name my_migration
prisma generateRun prisma generate whenever you need refreshed client code after schema-changing commands.
prisma generateRun before building your application.
generator client {
provider = "prisma-client"
output = "../generated"
}
generator zod {
provider = "zod-prisma-types"
output = "../generated/zod"
}prisma generate # Runs all generatorsAfter running prisma generate, your output directory contains:
generated/
├── browser.ts
├── client.ts
├── commonInputTypes.ts
├── models/
├── enums.ts
├── models.ts
└── ...Import the client:
import { PrismaClient, Prisma } from '../generated/prisma/client'Import browser-safe types:
import { Prisma } from '../generated/prisma/browser'
import { Role } from '../generated/prisma/enums'
import type { UserModel } from '../generated/prisma/models/User'