Skip to main content

Generators

A Prisma schema can have one or more generators, represented by the generator block:

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

A generator determines which assets are created when you run the prisma generate command.

There are two generators for Prisma Client:

  • prisma-client-js: Generates Prisma Client into node_modules
  • prisma-client (Early Access): Newer and more flexible version of prisma-client-js with ESM support; it outputs plain TypeScript code and requires a custom output path

Alternatively, you can configure any npm package that complies with our generator specification.

prisma-client-js

The prisma-client-js is the default generator for Prisma ORM 6.X versions and before. It requires the @prisma/client npm package and generates Prisma Client into node_modules.

Field reference

The generator for Prisma's JavaScript Client accepts multiple additional properties:

  • previewFeatures: Preview features to include
  • binaryTargets: Engine binary targets for prisma-client-js (for example, debian-openssl-1.1.x if you are deploying to Ubuntu 18+, or native if you are working locally)
generator client {
provider = "prisma-client-js"
previewFeatures = ["sample-preview-feature"]
binaryTargets = ["debian-openssl-1.1.x"] // defaults to `"native"`
}

Binary targets

The prisma-client-js generator uses several engines. Engines are implemented in Rust and are used by Prisma Client in the form of executable, platform-dependent engine files. Depending on which platform you are executing your code on, you need the correct file. "Binary targets" are used to define which files should be present for the target platform(s).

The correct file is particularly important when deploying your application to production, which often differs from your local development environment.

The native binary target

The native binary target is special. It doesn't map to a concrete operating system. Instead, when native is specified in binaryTargets, Prisma Client detects the current operating system and automatically specifies the correct binary target for it.

As an example, assume you're running macOS and you specify the following generator:

prisma/schema.prisma
generator client {
provider = "prisma-client-js"
binaryTargets = ["native"]
}

In that case, Prisma Client detects your operating system and finds the right binary file for it based on the list of supported operating systems . If you use macOS Intel x86 (darwin), then the binary file that was compiled for darwin will be selected. If you use macOS ARM64 (darwin-arm64), then the binary file that was compiled for darwin-arm64 will be selected.

Note: The native binary target is the default. You can set it explicitly if you wish to include additional binary targets for deployment to different environments.

prisma-client (Early Access)

The new prisma-client generator offers greater control and flexibility when using Prisma ORM across different JavaScript environments (such as ESM, Bun, Deno, ...).

It generates Prisma Client into a custom directory in your application's codebase that's specified via the output field on the generator block. This gives you full visibility and control over the generated code, including the query engine.

Currently in Early Access, this generator ensures you can bundle your application code exactly the way you want, without relying on hidden or automatic behaviors.

Here are the main differences compared to prisma-client-js:

  • Requires an output path; no “magic” generation into node_modules any more
  • Supports ESM and CommonJS via the moduleFormat field
  • More flexible thanks to additional fields
  • Outputs plain TypeScript that's bundled just like the rest of your application code

The prisma-client generator will become the new default with Prisma ORM v7.

Getting started

Follow these steps to use the new prisma-client generator in your project.

1. Configure the prisma-client generator in schema.prisma

Update your generator block:

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

The output option is required and tells Prisma ORM where to put the generated Prisma Client code. You can choose any location suitable for your project structure. For instance, if you have the following layout:

.
├── package.json
├── prisma
│ └── schema.prisma
├── src
│ └── index.ts
└── tsconfig.json

Then ../src/generated/prisma places the generated code in src/generated/prisma relative to schema.prisma.

2. Generate Prisma Client

Generate Prisma Client by running:

npx prisma generate

This generates the code for Prisma Client (including the query engine binary) into the specified output folder.

3. Exclude the generated directory from version control

The new generator includes both the TypeScript client code and the query engine. Including the query engine in version control can cause compatibility issues on different machines. To avoid this, add the generated directory to .gitignore:

.gitignore
# Keep the generated Prisma Client + query engine out of version control
/src/generated/prisma
note

In the future, you can safely include the generated directory in version control when Prisma ORM is fully transitioned from Rust to TypeScript.

4. Use Prisma Client in your application

After generating the Prisma Client, import the types from the path you specified:

src/index.ts
import { PrismaClient } from "./generated/prisma/client"

const prisma = new PrismaClient()

Prisma Client is now ready to use in your project.

Field reference

Use the following options in the generator client { ... } block. Only output is required. The other fields have defaults or are inferred from your environment and tsconfig.json.

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

// Optional
runtime = "nodejs"
moduleFormat = "esm"
generatedFileExtension = "ts"
importFileExtension = "ts"
}

Below are the options for the prisma-client generator:

OptionDefaultDescription
output (required)Directory where Prisma Client is generated, e.g. ../src/generated/prisma.
runtimenodejsTarget runtime environment.
Supported values:
nodejs (alias node), deno, bun, deno-deploy, workerd (alias cloudflare), edge-light (alias vercel), react-native.
moduleFormatInferred from environmentModule format (esm or cjs). Determines whether import.meta.url or __dirname is used.
generatedFileExtensiontsFile extension for generated TypeScript files (ts, mts, cts).
importFileExtensionInferred from environmentFile extension used in import statements. Can be ts, mts, cts, js, mjs, cjs, or empty (for bare imports).

Limitations

  • Namespace usage: The generated code still relies on TypeScript features like namespace, which may cause incompatibility with certain runtime-only setups (e.g., Node.js 22+ without --experimental-transform-types). It remains fully compatible with standard runtimes, tsx, ts-node, and most bundlers.
  • No browser bundle: There is currently no official browser build, and importing types or enums in frontend code is not supported.
note

Both limitations will be resolved soon in a future release.

Community generators

note

Existing generators or new ones should not be affected if you are using the prismaSchemaFolder preview feature to manage multiple schema files, unless a generator reads the schema manually.

The following is a list of community created generators.