Skip to main content

Prisma Config reference

Overview

warning

This feature is currently in Early Access and still subject to change.

The Prisma Config file is a TypeScript file that allows you to configure Prisma ORM. It accepts the following options:

NameTypeRequiredDescription
earlyAccessBooleanYesRequired while Prisma Config is in Early Access.
schemaObjectNoSpecifies the path to your Prisma schema (either as a single file or a folder if the Prisma schema is split across multiple files).

Reference

earlyAccess: Boolean

Description

While prisma.config.ts is running in Early Access, you need to explicitly enable it with this property.

Example

prisma.config.ts
export default {
earlyAccess: true,
};

schema: Object

Description

The schema property allows you to specify a custom path to the location of your Prisma schema file. It takes two properties:

  • kind: 'single' if you have a single .prisma file for your Prisma schema; 'multi' if you're using a the prismaSchemaFolder preview feature and split your data model across multiple .prisma files.
  • filePath for single-file schemas and folderPath for multi-file schemas.

Example

Specify the path to a single-file Prisma schema
prisma.config.ts
import path from "node:path";

export default {
schema: {
kind: "single",
filePath: path.join("custom", "prisma", "schema.prisma"),
},
};
Specify the path to a folder containing multiple Prisma schema files

This requires the prismaSchemaFolder Preview feature to be enabled.

prisma.config.ts
import path from "node:path";

export default {
schema: {
kind: "multi",
folderPath: path.join("custom", "prisma", "schema"),
},
};

Using Prisma Config

Installing the @prisma/config package to get auto-completion

In order to get auto-completion of properties in the Prisma Config file, you need to install the @prisma/config npm package:

npm install @prisma/config --save-dev

Adding Prisma Config to your project

prisma.config.ts needs to be present in the same folder where you're running Prisma CLI commands. We recommend placing it in the root of your entire project (not in the prisma folder), because that's where CLI commands are typically executed.

Manually loading environment variables

If you add a prisma.config.ts to your project, the Prisma CLI will not load your environment variables automatically from .env files.

Instead, you will need to manually load the environment variables using the dotenv package:

1. Install dotenv

npm install dotenv

2. Import 'dotenv/config' where needed

In files where you're accessing an environment variable defined in your .env file, add this line to the import statements:

prisma.config.ts
import "dotenv/config";

// now you can access env vars via:
// `process.env`
// for example:
// `process.env.DATABASE_URL`

Using a custom Prisma Config location/name

When invoking a Prisma CLI command, you can specify a custom location/name for the Prisma Config file using the --config option. For example:

prisma validate --config ./path/to/myconfig.ts