Skip to main content
Prisma Documentation Docs

Search documentation

Type to search this documentation.

On this pageOverview

init

The prisma init command bootstraps a fresh Prisma project within the current directory.

prisma init [options]

The command creates a prisma directory containing a schema.prisma file. By default, the project is configured for local Prisma Postgres, but you can choose a different database using the --datasource-provider option.

Option Description
-h, --help Display help message
--db Provision a fully managed Prisma Postgres database on the Prisma Data Platform
--datasource-provider Define the datasource provider: postgresql, mysql, sqlite, sqlserver, mongodb, or cockroachdb
--generator-provider Define the generator provider to use (default: prisma-client)
--preview-feature Define a preview feature to use (can be specified multiple times)
--output Define Prisma Client generator output path
--url Define a custom datasource URL
Flag Description
--with-model Add an example model to the created schema file

Sets up a new project configured for local Prisma Postgres:

title="bun"
bunx --bun prisma init
pnpm
pnpm prisma init
yarn
yarn prisma init
npm
npx prisma init

Set up a new project with MySQL as the datasource provider:

title="bun"
bunx --bun prisma init --datasource-provider mysql
pnpm
pnpm prisma init --datasource-provider mysql
yarn
yarn prisma init --datasource-provider mysql
npm
npx prisma init --datasource-provider mysql

Set up a project with the legacy prisma-client-js generator instead of the default prisma-client generator:

title="bun"
bunx --bun prisma init --generator-provider prisma-client-js
pnpm
pnpm prisma init --generator-provider prisma-client-js
yarn
yarn prisma init --generator-provider prisma-client-js
npm
npx prisma init --generator-provider prisma-client-js

Set up a project with specific preview features enabled:

title="bun"
bunx --bun prisma init --preview-feature metrics
pnpm
pnpm prisma init --preview-feature metrics
yarn
yarn prisma init --preview-feature metrics
npm
npx prisma init --preview-feature metrics

Multiple preview features:

title="bun"
bunx --bun prisma init --preview-feature views --preview-feature metrics
pnpm
pnpm prisma init --preview-feature views --preview-feature metrics
yarn
yarn prisma init --preview-feature views --preview-feature metrics
npm
npx prisma init --preview-feature views --preview-feature metrics

Set up a project with a custom output path for Prisma Client:

title="bun"
bunx --bun prisma init --output ./generated-client
pnpm
pnpm prisma init --output ./generated-client
yarn
yarn prisma init --output ./generated-client
npm
npx prisma init --output ./generated-client

Set up a project with a specific database URL:

title="bun"
bunx --bun prisma init --url mysql://user:password@localhost:3306/mydb
pnpm
pnpm prisma init --url mysql://user:password@localhost:3306/mydb
yarn
yarn prisma init --url mysql://user:password@localhost:3306/mydb
npm
npx prisma init --url mysql://user:password@localhost:3306/mydb

Set up a project with an example User model:

title="bun"
bunx --bun prisma init --with-model
pnpm
pnpm prisma init --with-model
yarn
yarn prisma init --with-model
npm
npx prisma init --with-model

Create a new project with a managed Prisma Postgres database:

bunx --bun prisma init --db
Bash
pnpm prisma init --db
Bash
yarn prisma init --db
Bash
npx prisma init --db

This requires authentication with the Prisma Data Platform Console.

This requires authentication with the Prisma Data Platform Console.

After running prisma init, you'll have the following files:

The Prisma schema file where you define your data model:

generator client {

  provider = "prisma-client"

  output   = "../generated/prisma"

}

datasource db {

  provider = "postgresql"

}

A TypeScript configuration file for Prisma:

import "dotenv/config";

import { defineConfig, env } from "prisma/config";

export default defineConfig({

  schema: "prisma/schema.prisma",

  migrations: {

    path: "prisma/migrations",

  },

  datasource: {

    url: env("DATABASE_URL"),

  },

});

Environment variables file for your project:

DATABASE_URL="postgresql://user:password@localhost:5432/mydb"

Git ignore file configured for Prisma projects:

node_modules

.env

/generated/prisma
Suggest an edit

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

Export
Documentation menu