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:
-
I'm creating a new app: Create an app from a template and run your first query.
-
I have an app, but no database yet: Add Prisma ORM to your app, create the tables, and apply your first migration.
-
I have a database already: Generate the file that holds your models from the tables you have, then make your next schema change.
-
I have a Prisma 7 app: Run Prisma ORM 8 next to Prisma ORM 7 in the same app, and move your code over in steps.
Prisma ORM 8 is the recommended starting point for new projects.
bun create prisma@latestpnpm create prisma@latestyarn create prisma@latestnpm create prisma@latest-
Deploy the full Prisma stack: Scaffold, provision Prisma Postgres, query, and deploy to Prisma Compute in one sitting.
-
Choose a setup path: Pick a new-project quickstart or add Prisma ORM to an existing app.
Add Prisma ORM to your framework
Section titled “Add Prisma ORM to your framework”Each guide runs the same journey for a specific framework: scaffold, connect Prisma Postgres, query, and deploy where the framework is supported on Compute.
Learn the fundamentals
Section titled “Learn the fundamentals”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.
Learn the concepts
Section titled “Learn the concepts”- Prisma ORM overview: Learn the core ideas behind contracts, emitted artifacts, runtime clients, query styles, and migrations.
Use with your agent
Section titled “Use with your agent”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:
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).