# Create a new app with MongoDB (/docs/prisma-orm/quickstart/mongodb) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Create a new Prisma ORM project with MongoDB using create-prisma@latest. Location: Prisma ORM > Quickstart > Create a new app with MongoDB This page uses MongoDB. [Use PostgreSQL instead](https://www.prisma.io/docs/prisma-orm/quickstart/postgresql). Create a Prisma ORM app with MongoDB, apply the first migration, and run your first query against seeded data. > [!NOTE] > Using Prisma ORM 7? > > Prisma ORM 8 is a release candidate. Prisma ORM 7 remains fully supported; its docs live at [/orm/v7](https://www.prisma.io/docs/orm/v7) and its setup paths at [/v7/getting-started](https://www.prisma.io/docs/v7/getting-started). > > For what release candidate means, when the final release is expected, and how to stay on version 7, see [Release status](https://www.prisma.io/docs/orm/release-status). ## Quick start [#quick-start] You need Node.js 22.18 or newer on the 22 line, 24.11 or newer on the 24 line, or 26 or newer; Node.js 24 is recommended. The npm that ships with your Node.js release works; on Node.js 22 that is npm 10. [Supported versions](https://www.prisma.io/docs/orm/supported-versions) has every floor. #### npm ```bash npm create prisma@latest -- --provider mongodb --no-deploy ``` #### pnpm ```bash pnpm create prisma@latest --provider mongodb --no-deploy ``` #### yarn ```bash yarn create prisma@latest --provider mongodb --no-deploy ``` #### bun ```bash bun create prisma@latest --provider mongodb --no-deploy ``` The command preselects MongoDB and prompts you for the project name, the template, the language you write your contract in (the contract is what Prisma ORM 7 called the schema, and you write it in Prisma Schema Language, as in `schema.prisma`, or in TypeScript), your package manager, and whether to install agent skills. If you would rather add Prisma ORM to a project by hand, without the generated template, follow [Set up Prisma ORM from scratch](https://www.prisma.io/docs/prisma-orm/from-scratch), which uses PostgreSQL. Setup gives you the app template, a starter contract, `prisma-8.md` (a short quick reference for writing your first typed query), project-level Prisma ORM skills for your coding agent, and package scripts for the database steps below. Answer no at the skills prompt, or pass `--skills none`, to skip the agent skill files; to remove them later, see [`skills sync`](https://www.prisma.io/docs/cli/skills) and the [`skills` config section](https://www.prisma.io/docs/cli/configuration#agent-skills). Sample users are seeded automatically the first time the app queries the database, so there is no separate seed step. When the project folder is new or empty and is not already inside a Git repository, setup also creates a Git repository with one commit, `Initial commit from create-prisma`. ## 1. Set the database connection [#1-set-the-database-connection] Run the remaining steps in the new project directory, such as `cd my-app` for a project named `my-app`. The scaffold writes a `.env` there with a local connection string: ```text title=".env" DATABASE_URL="mongodb://localhost:27017/mydb?replicaSet=rs0&directConnection=true" ``` Nothing in the generated project loads `.env`, so export `DATABASE_URL` in the shell you work in. Both the `prisma` commands and the app read it from there: ```bash export DATABASE_URL="mongodb://localhost:27017/mydb?replicaSet=rs0&directConnection=true" ``` The setup output also asks you to set `MONGODB_URL`. That variable is only for running or deploying the app with Prisma Composer, and this quickstart does not need it. The string names a replica set, `rs0`, but because it also sets `directConnection=true`, it connects to a standalone `mongod` on port 27017 as well, so you can use it as it is with either. A standalone server is enough for this quickstart, because a replica set is only needed for transactions and change streams. If you use MongoDB Atlas, which is already a replica set, use the connection string from your Atlas cluster instead. If you have no MongoDB server yet, [A database on your machine](https://www.prisma.io/docs/prisma-orm/local-database#mongodb) shows how to run one in Docker. ## 2. Create the migration plan [#2-create-the-migration-plan] Create the first migration plan from the starter contract. #### npm ```bash npm run migration:plan -- --name init ``` #### pnpm ```bash pnpm run migration:plan --name init ``` #### yarn ```bash yarn migration:plan --name init ``` #### bun ```bash bun run migration:plan --name init ``` The output reports the planned operations. With a PSL contract, it plans 3: it creates the `posts` and `users` collections and a unique index named `email_1` on `users.email`. The TypeScript starter contract declares no unique field, so with it the plan has 2 operations and no index. ## 3. Apply the migration [#3-apply-the-migration] Apply the planned migration to MongoDB: #### npm ```bash npm run migrate ``` #### pnpm ```bash pnpm run migrate ``` #### yarn ```bash yarn migrate ``` #### bun ```bash bun run migrate ``` `db migrate` also writes `migrations/app/refs/db.json`, the `db` ref, which records the contract state your development database is now at. Your next `migration plan` starts from it. The output includes `Applied 1 migration(s) (3 operation(s)) across 1 contract space(s)`, or `(2 operation(s))` with the TypeScript starter, and a line starting `Advanced ref "db"`. If it fails with a connection error, confirm `DATABASE_URL` is exported in this shell and points at a running MongoDB server. The `1 contract space` in the summary is the migration history for your own models. Prisma ORM calls it the `app` [contract space](https://www.prisma.io/docs/orm/migrations/the-migration-graph#terms-used-on-this-page), and its migrations are in `migrations/app/`. ## 4. Run the app [#4-run-the-app] Start the app and confirm the sample query runs successfully. #### npm ```bash npm run dev ``` #### pnpm ```bash pnpm run dev ``` #### yarn ```bash yarn dev ``` #### bun ```bash bun run dev ``` Use the URL or terminal output shown by your template. You should see the seeded users returned from MongoDB. ## Next steps [#next-steps] - Open `src/prisma/contract.prisma` or `src/prisma/contract.ts` and change the starter model. In the `turborepo` template, the contract is in `packages/database/src/` instead. Then run `npm run contract:emit`, `npm run migration:plan -- --name `, and `npm run migrate`. Without `contract:emit`, `migration plan` reads the contract from before your change and reports `No changes detected`. - If you already have an app, follow [Add Prisma ORM and MongoDB to an existing app](https://www.prisma.io/docs/prisma-orm/quickstart/existing-app/mongodb) when its database is empty, or [Add Prisma ORM to an existing MongoDB database](https://www.prisma.io/docs/prisma-orm/add-to-existing-project/mongodb) when the database already has collections. - Read the [Prisma ORM overview](https://www.prisma.io/docs/orm) when you want the concepts behind contracts, query APIs, and migrations. ## Related pages - [Create a new app with PostgreSQL](https://www.prisma.io/docs/prisma-orm/quickstart/postgresql): Create a new Prisma ORM project with PostgreSQL using create-prisma@latest.