Skip to main content
Prisma Documentation Docs

Search documentation

Type to search this documentation.

On this pageOverview

Introduction to Prisma Client

Prisma Client is an auto-generated and type-safe query builder that's tailored to your data. To get started with Prisma Client, follow the Quickstart.

⭐ Quickstart (5 min)

The setup instructions below provide a high-level overview of the steps needed to set up Prisma Client. If you want to get started using Prisma Client with your own database, follow one of these guides:

🚀 Set up a new project from scratch

➕ Add Prisma to an existing project

In order to set up Prisma Client, you need a Prisma schema file with your database connection, the Prisma Client generator, and at least one model:

title="schema.prisma"
datasource db {

  provider = "postgresql"

}

generator client {

  provider = "prisma-client"

  output   = "../src/generated/prisma"

}

model User {

  id        Int      @id @default(autoincrement())

  createdAt DateTime @default(now())

  email     String   @unique

  name      String?

}

Also make sure to install the Prisma CLI:

title="bun"
bun add prisma@6.19.3 --dev
pnpm
pnpm add prisma@6.19.3 --save-dev
yarn
yarn add prisma@6.19.3 --dev
npm
npm install prisma@6.19.3 --save-dev
title="bun"
bunx prisma
pnpm
pnpm prisma
yarn
yarn prisma
npm
npx prisma

Install Prisma Client in your project with the following command:

title="bun"
bun add @prisma/client@6.19.3
pnpm
pnpm add @prisma/client@6.19.3
yarn
yarn add @prisma/client@6.19.3
npm
npm install @prisma/client@6.19.3

There are multiple ways to import Prisma Client in your project depending on your use case:

title="TypeScript"
import { PrismaClient } from "./generated/prisma";

const prisma = new PrismaClient();

// use `prisma` in your application to read and write data in your DB
JavaScript
const { PrismaClient } = require("./generated/prisma");

const prisma = new PrismaClient();
// use `prisma` in your application to read and write data in your DB

For edge environments, you can import Prisma Client as follows:

import { PrismaClient } from "./generated/prisma/edge";

const prisma = new PrismaClient();

// use `prisma` in your application to read and write data in your DB
JavaScript
const { PrismaClient } = require("./generated/prisma/edge");

const prisma = new PrismaClient();
// use `prisma` in your application to read and write data in your DB

Note: If you're using driver adapters, you can import from the location specified in your generator's output path directly, e.g. ./src/generated/prisma. No need to import from ./src/generated/prisma/edge.

Note: If you're using driver adapters, you can import from the location specified in your generator's output path directly, e.g. ./src/generated/prisma. No need to import from ./src/generated/prisma/edge.

Once you have instantiated PrismaClient, you can start sending queries in your code:

// run inside `async` function

const newUser = await prisma.user.create({

  data: {

    name: "Alice",

    email: "alice@prisma.io",

  },

});

const users = await prisma.user.findMany();

Whenever you make changes to your database that are reflected in the Prisma schema, you need to manually re-generate Prisma Client to update the generated code in your output directory:

prisma generate
Suggest an edit

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

Export
Documentation menu