← All notes

· Prisma · NestJS · TypeScript

Prisma 7 in practice: driver adapters and the new client

We run Prisma 7 in production behind a NestJS API (it powers the live SQL showcase on this site). The upgrade is worth it, but four changes cost us real debugging time. Here they are, so they cost you less.

1. The datasource url no longer lives in the schema

Prisma 7 rejects url = env("DATABASE_URL") inside schema.prisma with error P1012. Connection config moves to prisma.config.ts, and the runtime client takes a driver adapter instead. If you copy an older tutorial, this is the first wall you hit.

// prisma.config.ts
import 'dotenv/config';
import { defineConfig } from 'prisma/config';

export default defineConfig({
  schema: 'prisma/schema.prisma',
  migrations: { path: 'prisma/migrations', seed: 'tsx prisma/seed.ts' },
  datasource: { url: process.env['DATABASE_URL'] },
});

2. Driver adapters are mandatory

The client no longer speaks to the database by itself — you construct it with an adapter. For SQLite that is @prisma/adapter-better-sqlite3; for Postgres, @prisma/adapter-pg. Watch the casing: the class is PrismaBetterSqlite3, not PrismaBetterSQLite3 — TypeScript will tell you, but only after you wonder why the import is undefined.

import { PrismaBetterSqlite3 } from '@prisma/adapter-better-sqlite3';
import { PrismaClient } from '../generated/prisma/client';

const adapter = new PrismaBetterSqlite3({ url: process.env.DATABASE_URL! });
const prisma = new PrismaClient({ adapter });

3. The new generator emits TypeScript, and CommonJS apps need one line

The provider is now "prisma-client" (not "prisma-client-js") and it writes TypeScript source into your project instead of a package inside node_modules. Running under NestJS (CommonJS), set moduleFormat = "cjs" in the generator block or the emitted imports will not resolve. Gitignore the output folder and regenerate on install.

4. Seed with tsx, not ts-node

The generated client imports its internals with explicit .js extensions. ts-node cannot resolve those from .ts sources and dies with "Cannot find module ./internal/class.js" — after your seed file already type-checked. tsx resolves them fine. One word in prisma.config.ts saves you an evening.

None of this is a reason to skip Prisma 7 — the adapter model is cleaner and the generated client is easier to read than the old black box. It is just a migration with four sharp corners, and now you know where they are.