Build the Data Layer
12 min read
Install and Configure Prisma
Install and Configure Prisma
Now give the application a typed data-access layer for PostgreSQL.
Task
Install Prisma and configure the project to generate the standard Prisma client.
Install
Run:
npm install @prisma/client
npm install -D prisma
Initialize Prisma:
npx prisma init
This creates the Prisma schema and connects Prisma configuration to DATABASE_URL.
Configure the Generator
Open prisma/schema.prisma and use the Prisma Client generator:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
Do not create application models yet. The next lessons will build the schema incrementally.
Generate the Client
Run:
npx prisma generate
Test
Confirm that Prisma generates successfully without a schema validation error.
Checkpoint
The project now has Prisma configured for PostgreSQL, but no Readly models yet.