What this thread does
Use stable Prisma 7.10.1 with @prisma/adapter-better-sqlite3, and give migrations and runtime the same SQLite file URL.
Do first: run mkdir prisma-sqlite-demo for a new Node project
Use a Node release supported by Prisma's requirements, currently ^20.19.0, ^22.12.0 or ^24.0.0; the stable release is 7.10.1 — checked 2026-10-28. This recipe starts a new database, not an upgrade of an existing one. Before running the install commands, confirm that the client and adapter are both published at 7.10.1; otherwise select a published compatible set.
mkdir prisma-sqlite-demo
cd prisma-sqlite-demo
npm init -y
npm pkg set type=module
npm install --save-dev prisma@7.10.1 typescript tsx @types/node @types/better-sqlite3
npm install @prisma/client@7.10.1 @prisma/adapter-better-sqlite3@7.10.1
npx prisma init --datasource-provider sqlite --output ../generated/prisma
Create database-url.ts in the project root:
export const databaseUrl = new URL("./dev.db", import.meta.url).href;
Replace the generated prisma7.config.ts with this explicit local-file configuration; keep only this intended Prisma config:
import { defineConfig } from "prisma/config";
import { databaseUrl } from "./database-url";
console.log("CLI database URL:", databaseUrl);
export default defineConfig({
schema: "prisma/schema.prisma",
migrations: { path: "prisma/migrations" },
datasource: { url: databaseUrl },
});
Set prisma/schema.prisma to:
generator client {
provider = "prisma-client"
output = "../generated/prisma"
}
datasource db {
provider = "sqlite"
}
model Note {
id Int @id @default(autoincrement())
text String
}
The generator documentation requires an output directory for prisma-client; import from that generated location.
Run from the project root:
npx prisma migrate dev --name init
npx prisma generate
Create script.ts in that root:
import { PrismaBetterSqlite3 } from "@prisma/adapter-better-sqlite3";
import { PrismaClient } from "./generated/prisma/client";
import { databaseUrl } from "./database-url";
console.log("Runtime database URL:", databaseUrl);
const adapter = new PrismaBetterSqlite3({ url: databaseUrl });
const prisma = new PrismaClient({ adapter });
try {
await prisma.note.create({ data: { text: "SQLite is connected" } });
const notes = await prisma.note.findMany();
if (!notes.some(n => n.text === "SQLite is connected")) {
throw new Error("Inserted note was not returned");
}
console.log(notes);
} finally {
await prisma.$disconnect();
}
npx tsx script.ts
Success means the inserted note is printed and the process exits successfully. Compare the printed CLI and runtime URLs before relying on the setup. Each run intentionally inserts another note; this check does not establish persistence across processes. The SQLite quickstart documents the migration, generation and adapter flow. Preserve the generated migration and lockfile; exclude the development database from version control.
When this setup wins or loses
| Option and purpose | Wins when | Loses when | Pick this if |
|---|---|---|---|
| Local SQLite with better-sqlite3 | A Node process owns a local file for a prototype, small app or local tool | The deployment has ephemeral storage or many processes need shared writes | You control persistent local storage and can install the native driver |
| Hosted SQLite-compatible service | You explicitly need a remote managed database | You only need a disposable local file and would add unnecessary operations | The deployment requires remote persistence; follow the provider's adapter guide instead |
The Prisma SQLite connector distinguishes local, libSQL and D1 adapters. SQLite's deployment guidance explains its local-storage focus and one-writer-at-a-time constraint. Local SQLite needs no database-server subscription, but backups, durable storage and hosted alternatives have their own costs; no hosted price is implied — checked 2026-10-28.
Public user evidence
lostfictions, Prisma #23837, 2024-04-12: “passing an invalid database file path” can create an empty database. This older report motivates matching the CLI and application paths; it does not prove a defect in this stable recipe.
Recommendation by constraint
Solo and small teams can use this local recipe for a prototype or one-server app with durable storage. Enterprise teams should decide database ownership, backups and write concurrency before treating it as shared production storage.
Prompt for the agent
Set up a fresh Prisma SQLite project with the stable pinned packages above. Keep CLI and runtime file paths identical. Generate the client and create a note. Report the resolved database file and deployment storage assumptions.
Mistakes
Do not import a client from a different output directory. Do not omit the runtime adapter. Do not treat migrate dev as a production deployment command. A successful build does not show that the deployment keeps the file across restarts.
Limits
The installation and database round trip were not run. The native driver must work on the target platform. This is not a Bun, edge runtime, hosted SQLite or existing-database migration recipe.
Started from a post by @Prisma documentation, packaged by the editor. Original post