Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,16 @@ metaTitle: Add Prisma Next to an existing MongoDB project
metaDescription: Add Prisma Next to an existing MongoDB project.
---

This guide shows how to add Prisma Next to a project that already uses MongoDB. You will initialize Prisma Next, describe the collections you want to work with, emit the generated artifacts, and run a couple of queries.
This guide shows how to add Prisma Next to a project that already uses MongoDB. You will run `prisma-next init`, describe the collections you want to work with, emit the generated artifacts, and run a couple of queries.

Use this path when you already have an application and database. Make sure the app can already reach its MongoDB deployment and runs on Node.js 24 or newer. If you want Prisma Next to create a new app for you, use the [MongoDB quickstart](/next/quickstart/mongodb).

:::warning[Prisma Next is still in development]

Prisma Next is not ready for production yet. Prisma ORM 7 is still the recommended choice for production applications today.

:::

## Prerequisites

Before you start, make sure you can already reach the MongoDB deployment this project uses today.

- Node.js 24 or newer
- npm
- An existing MongoDB 6.0 or newer deployment

For local development, use a replica set. MongoDB Atlas already gives you that.

## 1. Make sure you can run the example script
Expand All @@ -41,12 +35,15 @@ Later, `prisma-next init` will also add the Node.js types it needs and make sure
From the root of your existing project, run:

```npm
npx prisma-next init --write-env
npx prisma-next init --target mongodb
```

When Prisma Next asks a few setup questions:
This is the existing-project path. It preselects MongoDB, adds Prisma Next files and package scripts to the app you already have, and does not scaffold a new framework project.

It also adds `prisma-next.md` and project-level Prisma Next skills for Cursor, Claude Code, Codex, and Windsurf so your agent can read the Prisma Next usage, upgrade, and extension-author guidance from the project.

When Prisma Next asks the remaining setup questions:

- choose `MongoDB`
- choose `PSL`
- keep the default schema path, `prisma/contract.prisma`

Expand All @@ -55,7 +52,7 @@ When Prisma Next asks a few setup questions:
Update `.env` with the connection string for the MongoDB deployment your app already uses:

```text title=".env"
DATABASE_URL="mongodb://127.0.0.1:27017/my-app?replicaSet=rs0"
DATABASE_URL="mongodb://127.0.0.1:27017/app?replicaSet=rs0"
```

## 4. Describe the collections you want Prisma Next to know about
Expand Down Expand Up @@ -166,21 +163,12 @@ Run it again:
npx tsx script.ts
```

## 8. Commands you will use next
## 8. Next steps

Once Prisma Next is in the project, these are the MongoDB commands to remember:
When you change `prisma/contract.prisma`, emit the contract again:

```npm
npx prisma-next contract emit
```

Run this after you change `prisma/contract.prisma`.

```npm
npx prisma-next migration plan --name add-user-bio
npx prisma-next migration apply
```

Use these when you want Prisma Next to manage a schema change for the collections in your contract.

You do not need to create a migration just to start reading collections that already exist. Create a migration when you are ready for Prisma Next to own a change.
You do not need a migration just to read collections that already exist. Use [migration plan](/cli/next/migration-plan) when you want Prisma Next to own a schema change.
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
---
title: Postgres
title: PostgreSQL
description: Add Prisma Next to an existing PostgreSQL project.
url: /next/add-to-existing-project/postgresql
metaTitle: Add Prisma Next to an existing Postgres project
metaTitle: Add Prisma Next to an existing PostgreSQL project
metaDescription: Add Prisma Next to an existing PostgreSQL project.
---

This guide shows how to add Prisma Next to a project that already uses PostgreSQL. You will initialize Prisma Next, infer a contract from the live schema, sign the database, and run a couple of queries.
This guide shows how to add Prisma Next to a project that already uses PostgreSQL. You will run `prisma-next init`, infer a contract from the live schema, sign the database, and run a couple of queries.

Use this path when you already have an application and database. Make sure the app can already reach its PostgreSQL database and runs on Node.js 24 or newer. If you want Prisma Next to create a new app for you, use the [PostgreSQL quickstart](/next/quickstart/postgresql).

:::warning[Prisma Next is still in development]

Prisma Next is not ready for production yet. Prisma ORM 7 is still the recommended choice for production applications today.

:::

## Prerequisites

Before you start, make sure you can already reach the PostgreSQL database this project uses today.

- Node.js 24 or newer
- npm
- An existing PostgreSQL database

## 1. Make sure you can run the example script

If your project already runs TypeScript scripts, you can skip this step.
Expand All @@ -39,12 +33,15 @@ Later, `prisma-next init` will also add the Node.js types it needs and make sure
From the root of your existing project, run:

```npm
npx prisma-next init --write-env
npx prisma-next init --target postgres
```

When Prisma Next asks a few setup questions:
This is the existing-project path. It preselects PostgreSQL, adds Prisma Next files and package scripts to the app you already have, and does not scaffold a new framework project.

It also adds `prisma-next.md` and project-level Prisma Next skills for Cursor, Claude Code, Codex, and Windsurf so your agent can read the Prisma Next usage, upgrade, and extension-author guidance from the project.

When Prisma Next asks the remaining setup questions:

- choose `PostgreSQL`
- choose `PSL`
- keep the default schema path, `prisma/contract.prisma`

Expand Down Expand Up @@ -166,25 +163,12 @@ Run it again:
npx tsx script.ts
```

## 9. Commands you will use next
## 9. Next steps

Once Prisma Next is in the project, these are the PostgreSQL commands to remember:
When you change `prisma/contract.prisma`, emit the contract again:

```npm
npx prisma-next contract emit
```

Run this after you change `prisma/contract.prisma`.

```npm
npx prisma-next db update
```

Use this when you want Prisma Next to update the live database directly so it matches the latest contract.

```npm
npx prisma-next migration plan --name add-user-bio
npx prisma-next migration apply
```

Use these when you want checked-in migration packages instead of a direct database update.
Use [db update](/cli/next/db-update) for a direct development update, or [migration plan](/cli/next/migration-plan) when you want a checked-in migration.
80 changes: 0 additions & 80 deletions apps/docs/content/docs/(index)/next/create-prisma.mdx

This file was deleted.

62 changes: 62 additions & 0 deletions apps/docs/content/docs/(index)/next/getting-started.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: Choose a setup path
description: Choose the fastest path to try Prisma Next in a new or existing project.
url: /next/getting-started
metaTitle: Prisma Next getting started
metaDescription: Choose a Prisma Next quickstart for a new project or add Prisma Next to an existing app.
badge: early-access
---

Start with a quickstart if you want Prisma Next to create the app. Use the existing-project path if you already have an app and database.

## Start a new project

```npm
npx create-prisma@next
```

<Cards>
<Card href="/next/quickstart/postgresql" title="Quickstart with PostgreSQL" icon={<Rocket className="text-primary" />}>
Create the app, choose PostgreSQL, initialize the database, seed data, and run the first query.
</Card>
<Card href="/next/quickstart/mongodb" title="Quickstart with MongoDB" icon={<Database className="text-primary" />}>
Create the app, choose MongoDB, start or connect to MongoDB, seed data, and run the first query.
</Card>
</Cards>

## Use Prisma Postgres

```npm
npx create-prisma@next
```

<Cards>
<Card href="/next/prisma-postgres/quickstart/prisma-next" title="Quickstart with Prisma Postgres" icon={<Database className="text-primary" />}>
Create a Prisma Next app and let setup provision Prisma Postgres for the first run.
</Card>
<Card href="/next/prisma-postgres/from-the-cli" title="From the CLI" icon={<Terminal className="text-primary" />}>
Start from the command line when you want the Prisma Postgres path without browsing Console first.
</Card>
</Cards>

## Add to an existing project

```npm
npx prisma-next init
```

<Cards>
<Card href="/next/add-to-existing-project/postgresql" title="Add to PostgreSQL" icon={<Database className="text-primary" />}>
Add Prisma Next to an existing PostgreSQL app and infer a starter contract from the live schema.
</Card>
<Card href="/next/add-to-existing-project/mongodb" title="Add to MongoDB" icon={<Database className="text-primary" />}>
Add Prisma Next to an existing MongoDB app and model the collections you want to query first.
</Card>
</Cards>

## After setup

- Use the generated app scripts for the first run.
- Open `prisma-next.md` or the installed Prisma Next skills when you want agent-ready guidance inside the project.
- Change the starter contract when you are ready to model your own data.
- Open the [Prisma Next overview](/orm/next) when you want the concepts behind the setup.
63 changes: 46 additions & 17 deletions apps/docs/content/docs/(index)/next/index.mdx
Original file line number Diff line number Diff line change
@@ -1,29 +1,58 @@
---
title: Get started with Prisma Next
description: Start a new Prisma Next app or add Prisma Next to an existing project.
title: Introduction to Prisma Next
description: Prisma Next is the next foundation for Prisma ORM.
url: /next
metaTitle: Get started with Prisma Next
metaDescription: Start a Prisma Next project with create-prisma@next or add Prisma Next to an existing project.
metaTitle: Introduction to Prisma Next
metaDescription: Prisma Next is the next foundation for Prisma ORM.
badge: early-access
---

Prisma Next is the next foundation for Prisma ORM. Start here if you want to try the Prisma Next workflow.
Prisma Next is the next foundation for Prisma ORM. It is an early access version of the ORM runtime, query APIs, migration flow, and project setup.

:::warning[Prisma Next is still in development]

Prisma Next is not ready for production yet. Prisma ORM 7 is still the recommended choice for production applications today.

:::

## Start a new project

- [Scaffold a Prisma Next app with create-prisma@next](/next/create-prisma)

## Add Prisma Next to an existing project

- [Add Prisma Next to an existing PostgreSQL project](/next/add-to-existing-project/postgresql)
- [Add Prisma Next to an existing MongoDB project](/next/add-to-existing-project/mongodb)

## Learn the ORM workflow

Read the [Prisma Next overview](/orm/next) to learn about contracts, emitted artifacts, runtime clients, query styles, and database change commands.
Use Prisma Next when you want to try the new developer experience before it becomes the default Prisma ORM path.

```npm
npx create-prisma@next
```

Start with the setup page when you want a guided first run.

<Cards>
<Card href="/next/getting-started" title="Choose a setup path" icon={<Rocket className="text-primary" />}>
Pick a new-project quickstart or add Prisma Next to an existing app.
</Card>
</Cards>

## What you can try

<Cards>
<Card href="/next/quickstart/postgresql" title="Quickstart with PostgreSQL" icon={<Rocket className="text-primary" />}>
Create a Prisma Next app, initialize the database, seed data, and run the first query.
</Card>
<Card href="/next/quickstart/mongodb" title="Quickstart with MongoDB" icon={<Database className="text-primary" />}>
Create a Prisma Next app with a local MongoDB replica set or your own MongoDB deployment.
</Card>
<Card href="/next/add-to-existing-project/postgresql" title="Add to PostgreSQL" icon={<Database className="text-primary" />}>
Add Prisma Next to an existing PostgreSQL app with `prisma-next init`.
</Card>
<Card href="/next/add-to-existing-project/mongodb" title="Add to MongoDB" icon={<Database className="text-primary" />}>
Add Prisma Next to an existing MongoDB app and model the collections you want to query first.
</Card>
<Card href="/next/prisma-postgres/quickstart/prisma-next" title="Use Prisma Postgres" icon={<Database className="text-primary" />}>
Create a Prisma Next app backed by Prisma Postgres.
</Card>
</Cards>

## Learn the concepts

<Cards>
<Card href="/orm/next" title="Prisma Next overview" icon={<BookOpen className="text-primary" />}>
Learn the core ideas behind contracts, emitted artifacts, runtime clients, query styles, and migrations.
</Card>
</Cards>
10 changes: 7 additions & 3 deletions apps/docs/content/docs/(index)/next/meta.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"title": "Next",
"title": "Prisma Next",
"defaultOpen": true,
"root": true,
"pages": [
"---Getting Started---",
"index",
"create-prisma",
"add-to-existing-project"
"getting-started",
"---Prisma ORM---",
"quickstart",
"add-to-existing-project",
"---Prisma Postgres---",
"...prisma-postgres"
]
}
Loading
Loading