Skip to main content
Prisma Documentation Docs
current

Search documentation

Type to search this documentation.

On this pageOverview

Introduction to Prisma ORM

Prisma ORM 8 is the current release.

Prisma ORM 8 is a ground-up rebuild of Prisma ORM, from the runtime and query APIs to the migration flow and project setup.

Pick the page that matches where you are starting from:

Prisma ORM 8 is the recommended starting point for new projects.

bun
bun create prisma@latest
pnpm
pnpm create prisma@latest
yarn
yarn create prisma@latest
npm
npm create prisma@latest

Each guide runs the same journey for a specific framework: scaffold, connect Prisma Postgres, query, and deploy where the framework is supported on Compute.

Once you are connected, the Fundamentals section teaches the everyday query patterns.

  • Reading data: Filter with where, project with select, sort, and paginate.

  • Writing data: Create, update, delete, upsert, and the bulk write variants.

  • Relations and joins: Read related records with include on PostgreSQL and MongoDB.

  • Transactions: Make several writes succeed or fail together.

  • Advanced queries: The SQL builder and the MongoDB pipeline builder for shapes the ORM can't express.

  • Prisma ORM overview: Learn the core ideas behind contracts, emitted artifacts, runtime clients, query styles, and migrations.

Copy this prompt, replace the placeholders, and hand it to your coding agent. Running npx prisma@latest init after the scaffold installs the Prisma ORM skills that ship inside the installed Prisma packages and keeps them current:

text
Create a new [framework] application with Prisma ORM, seed it, and run it locally.

If I have not told you which framework, stop and ask before scaffolding. Valid --template values: minimal (the default), next, hono, nuxt, astro, nest, svelte, tanstack-start, elysia.

1. Scaffold the app: `npm create prisma@latest -- my-app --template [framework] --provider postgres --yes`. Then run `npx prisma@latest init` in the project directory so the Prisma agent skills are installed and stay current, and use them.
2. Get a database connection string: use the one I give you, or create a Prisma Postgres database in the project the app will deploy to: check `npx prisma auth whoami` (if I am not signed in, stop and ask me to run `npx prisma auth login`), then `npx prisma project create my-app` and `npx prisma postgres create mydb`, which prints the connection string once. Export it as `DATABASE_URL` in the shell; the generated scripts read the environment variable.
3. From the project directory, apply the starter contract: `npm run db:init`. Sample users are seeded automatically on the app's first query; there is no separate seed script.
4. Edit the starter contract under `src/prisma/` into a small schema for my use case, then run `npm run contract:emit` and plan and apply the migration: `npx prisma migration plan`, then `npx prisma db migrate --yes`. Migration planning diffs the emitted contract, so the emit step is required.
5. Update the seed script under `src/prisma/` and the app routes to query the new schema, start `npm run dev` in the background (with `DATABASE_URL` exported), and verify with a request against the running app. For the `nest` template, if routes return 500s with `reading 'findAll'` in the logs, add explicit `@Inject()` tokens as shown in https://www.prisma.io/docs/guides/frameworks/nestjs.md.
6. Deploy with Prisma Compute. If the template is `svelte`, skip this step; Compute does not support SvelteKit yet. The scaffold declares the app for Prisma Composer in `module.ts` and `service.ts`, with the framework's build requirements (Next.js standalone output, Astro's node adapter, TanStack Start's Nitro build) already configured; the framework guide at https://www.prisma.io/docs/guides/frameworks/[guide].md has the details, where [guide] is the template name except: template `next` → guide `nextjs`, `nest` → `nestjs`. Check `npx prisma auth whoami`. If I am not signed in, stop and ask me to run `npx prisma auth login`, because that step opens a browser. Then run `npm run build` followed by `npx prisma deploy module.ts`, and verify the deployed URL with curl. The deployed app provisions and seeds its own Prisma Postgres database; do not pass the local DATABASE_URL. If the deploy fails with `HostedStateBootstrapError`, a project with the module's name exists in my workspace but its hosted state cannot be verified; re-run the deploy with `--name <a unique name>`.

Use the installed Prisma ORM skills and the current Prisma docs: https://www.prisma.io/docs/llms.txt (append `.md` to any docs URL for a markdown version).
Suggest an edit

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

Export
Documentation menu