Skip to main content
Prisma Documentation Docs

Search documentation

Type to search this documentation.

On this pageOverview

PostgreSQL

Create a Prisma ORM app with PostgreSQL and run your first query against seeded data.

bun create prisma@latest --provider postgres --no-deploy
Bash
pnpm create prisma@latest --provider postgres --no-deploy
Bash
yarn create prisma@latest --provider postgres --no-deploy
Bash
npm create prisma@latest -- --provider postgres --no-deploy

Run this from a Node.js 22.18 or newer (on the 24 line, 24.11 or newer) environment; Node.js 24 is recommended. The command preselects PostgreSQL and prompts you for the project name, the template, the contract authoring style (PSL or 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.

Setup gives you the app template, a starter contract, prisma-8.md, 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 and the skills config section. Sample users are seeded automatically the first time the app queries the database, so there is no separate seed step.

From here you have two paths: let Prisma Composer run a local Prisma Postgres database for you, or connect a PostgreSQL database you provide.

Run this from a Node.js 22.18 or newer (on the 24 line, 24.11 or newer) environment; Node.js 24 is recommended. The command preselects PostgreSQL and prompts you for the project name, the template, the contract authoring style (PSL or 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.

Setup gives you the app template, a starter contract, prisma-8.md, 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 and the skills config section. Sample users are seeded automatically the first time the app queries the database, so there is no separate seed step.

From here you have two paths: let Prisma Composer run a local Prisma Postgres database for you, or connect a PostgreSQL database you provide.

Composer builds the app, starts a local Prisma Postgres database, and applies the starter contract for you, so you do not need a connection string.

title="bun"
bun run dev:composer
pnpm
pnpm run dev:composer
yarn
yarn dev:composer
npm
npm run dev:composer

Open the URL the command prints. You should see the seeded users returned from PostgreSQL.

Export DATABASE_URL in the shell you run the commands from. The generated scripts read the variable from the environment, not from .env.

export DATABASE_URL="postgresql://username:password@host:5432/database?sslmode=require"

If you don't have a PostgreSQL database yet, npx create-db@latest creates a temporary Prisma Postgres database and prints its connection string, plus a claim URL if you want to keep it.

From the generated project directory, run db:init to apply the starter contract to PostgreSQL and sign the database.

title="bun"
bun run db:init
pnpm
pnpm run db:init
yarn
yarn db:init
npm
npm run db:init

The output ends with a summary like Applied 5 operation(s) across 1 space(s), database signed.

Start the app and confirm the sample query runs successfully.

bun run dev
Bash
pnpm run dev
Bash
yarn dev
Bash
npm run dev

Use the URL or terminal output shown by your template. You should see the seeded users returned from PostgreSQL. If the response is Could not query users yet, DATABASE_URL is not set in the environment the app runs in; export it in the same shell and restart.

Use the URL or terminal output shown by your template. You should see the seeded users returned from PostgreSQL. If the response is Could not query users yet, DATABASE_URL is not set in the environment the app runs in; export it in the same shell and restart.

  • Open src/prisma/contract.prisma or src/prisma/contract.ts and change the starter model.
  • Use the PostgreSQL existing-project guide if you already have an app and database.
  • Read the Prisma ORM overview when you want the concepts behind contracts, query APIs, and migrations.
Suggest an edit

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

Export
Documentation menu