# init (Prisma CLI v7)

Set up a new Prisma project in the current directory

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

## Usage

```bash
prisma init [options]
```

The command creates a `prisma` directory containing a `schema.prisma` file. By default, the project is configured for [local Prisma Postgres](/guides/local-development-2-postgres), but you can choose a different database using the `--datasource-provider` option.

## Options

| 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                                                                            |

## Flags

| Flag           | Description                                     |
| -------------- | ----------------------------------------------- |
| `--with-model` | Add an example model to the created schema file |

## Examples

### Set up a new Prisma project (default)

Sets up a new project configured for local Prisma Postgres:

:::code-group
```bash title="bun"
bunx --bun prisma init
```

```bash title="pnpm"
pnpm prisma init
```

```bash title="yarn"
yarn prisma init
```

```bash title="npm"
npx prisma init
```
:::

### Specify a datasource provider

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

:::code-group
```bash title="bun"
bunx --bun prisma init --datasource-provider mysql
```

```bash title="pnpm"
pnpm prisma init --datasource-provider mysql
```

```bash title="yarn"
yarn prisma init --datasource-provider mysql
```

```bash title="npm"
npx prisma init --datasource-provider mysql
```
:::

### Specify a generator provider

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

:::code-group
```bash title="bun"
bunx --bun prisma init --generator-provider prisma-client-js
```

```bash title="pnpm"
pnpm prisma init --generator-provider prisma-client-js
```

```bash title="yarn"
yarn prisma init --generator-provider prisma-client-js
```

```bash title="npm"
npx prisma init --generator-provider prisma-client-js
```
:::

### Specify preview features

Set up a project with specific preview features enabled:

:::code-group
```bash title="bun"
bunx --bun prisma init --preview-feature metrics
```

```bash title="pnpm"
pnpm prisma init --preview-feature metrics
```

```bash title="yarn"
yarn prisma init --preview-feature metrics
```

```bash title="npm"
npx prisma init --preview-feature metrics
```
:::

Multiple preview features:

:::code-group
```bash title="bun"
bunx --bun prisma init --preview-feature views --preview-feature metrics
```

```bash title="pnpm"
pnpm prisma init --preview-feature views --preview-feature metrics
```

```bash title="yarn"
yarn prisma init --preview-feature views --preview-feature metrics
```

```bash title="npm"
npx prisma init --preview-feature views --preview-feature metrics
```
:::

### Specify a custom output path

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

:::code-group
```bash title="bun"
bunx --bun prisma init --output ./generated-client
```

```bash title="pnpm"
pnpm prisma init --output ./generated-client
```

```bash title="yarn"
yarn prisma init --output ./generated-client
```

```bash title="npm"
npx prisma init --output ./generated-client
```
:::

### Specify a custom datasource URL

Set up a project with a specific database URL:

:::code-group
```bash title="bun"
bunx --bun prisma init --url mysql://user:password@localhost:3306/mydb
```

```bash title="pnpm"
pnpm prisma init --url mysql://user:password@localhost:3306/mydb
```

```bash title="yarn"
yarn prisma init --url mysql://user:password@localhost:3306/mydb
```

```bash title="npm"
npx prisma init --url mysql://user:password@localhost:3306/mydb
```
:::

### Add an example model

Set up a project with an example `User` model:

:::code-group
```bash title="bun"
bunx --bun prisma init --with-model
```

```bash title="pnpm"
pnpm prisma init --with-model
```

```bash title="yarn"
yarn prisma init --with-model
```

```bash title="npm"
npx prisma init --with-model
```
:::

### Provision a Prisma Postgres database

Create a new project with a managed Prisma Postgres database:

:::code-group
```bash title="bun"
bunx --bun prisma init --db
```

```bash title="pnpm"
pnpm prisma init --db
```

```bash title="yarn"
yarn prisma init --db
```

```bash title="npm"
npx prisma init --db
```
:::

This requires authentication with the [Prisma Data Platform Console](https://console.prisma.io/?utm_source=docs\&utm_medium=content\&utm_content=cli).

## Generated files

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

### `prisma/schema.prisma`

The Prisma schema file where you define your data model:

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

datasource db {
  provider = "postgresql"
}
```

### `prisma.config.ts`

A TypeScript configuration file for Prisma:

```typescript
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"),
  },
});
```

### `.env`

Environment variables file for your project:

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

### `.gitignore`

Git ignore file configured for Prisma projects:

```bash
node_modules
.env
/generated/prisma
```

## Related pages

- [Authentication & Tools](./authentication-tools-index.md)
- [Build](./build-index.md)
- [Changelog](../changelog.md)
- [Concepts](./concepts-index.md)
- [Console commands](./console-commands-index.md)
- [Contract Authoring](./contract-authoring-index.md)
- [Core Concepts](./core-concepts-index.md)
- [Data Modeling](./data-modeling-index.md)
- [Database](./database-index.md)
- [DB commands](./db-commands-index.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
