Registry / database / prisma-adapter-bun-sqlite

prisma-adapter-bun-sqlite

JSON →
library0.8.0jsnpmunverified

prisma-adapter-bun-sqlite v0.8.0 is a Prisma driver adapter for Bun's native SQLite (bun:sqlite). It requires Bun >=1.3.0 and @prisma/client ^7.0.0, ships TypeScript types, and has zero dependencies beyond Bun. It supports WAL mode, safe integers, timestamp format options (iso8601/unixepoch-ms), programmatic migrations, and is designed for single-binary deployment with `bun build --compile`. Unlike alternatives (libsql, better-sqlite3), it uses Bun's native SQLite, is fully tested with 154 tests including 39 from Prisma's official suite, and provides proper error mapping to Prisma error codes (P2002, P2003, etc.). Release cadence: active development with frequent releases.

npm install prisma-adapter-bun-sqlite
INSTALL
IMPORT
SIG · PRISMA-ADAPTER-BUN
P
prisma-adapter-bun-sqlite
databasejavascriptv0.8.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PrismaBunSqlite
import { PrismaBunSqlite } from 'prisma-adapter-bun-sqlite'
import PrismaBunSqlite from 'prisma-adapter-bun-sqlite'
Named export only; default import is not supported.
PrismaClient
import { PrismaClient } from './path/to/generated/client'
import { PrismaClient } from '@prisma/client'
In Prisma 7+, PrismaClient must be imported from the generated output path, not from @prisma/client. The generated path is specified by the `output` field in schema.prisma.
PrismaBunSqlite options
const adapter = new PrismaBunSqlite({ url: 'file:./db.sqlite', wal: { enabled: true } })
const adapter = new PrismaBunSqlite('file:./db.sqlite')
Constructor expects an options object, not a string. Also `wal` was added in v0.8.0.

Shows basic setup: import PrismaBunSqlite and generated PrismaClient, instantiate adapter with url, create PrismaClient, perform CRUD, and optionally run programmatic migrations.

// prisma/schema.prisma // generator client { // provider = "prisma-client" // engineType = "client" // runtime = "bun" // output = "./generated" // } // datasource db { // provider = "sqlite" // } import { PrismaClient } from './path/to/prisma/generated/client'; import { PrismaBunSqlite } from 'prisma-adapter-bun-sqlite'; const adapter = new PrismaBunSqlite({ url: 'file:./db.sqlite', safeIntegers: true }); const prisma = new PrismaClient({ adapter }); // Example: create and query users await prisma.user.create({ data: { name: 'Alice', email: 'alice@example.com' } }); const users = await prisma.user.findMany(); console.log(users); // Programmatic migration (optional) import { migrate } from 'prisma-adapter-bun-sqlite'; await migrate({ migrationsPath: './prisma/migrations' });
Debug
Known issues
breakingPrismaBunSqlite constructor now expects an options object (not a string).
fix
Use `new PrismaBunSqlite({ url: 'file:./db.sqlite' })` instead of `new PrismaBunSqlite('file:./db.sqlite')`.
affects: >=0.8.0
deprecatedThe `maxBoundLength` option from earlier versions is removed.
fix
Remove `maxBoundLength`; not needed in v0.8.0.
affects: <0.8.0
gotchaPrismaClient must be imported from the generated output path, not from '@prisma/client'. Using `@prisma/client` directly leads to missing adapter support.
fix
Update schema.prisma to set `output` and import from that path (e.g., './prisma/generated/client').
affects: >=7.0.0
gotchaIf using `:memory:` database, data is lost when connection closes.
fix
Use a file-based URL for persistent storage.
affects: >=0.1.0
breakingRequires Bun >=1.3.0. Older Bun versions will throw a compatibility error.
fix
Update Bun to version 1.3.0 or later.
affects: >=0.8.0
gotchaThe `wal` option with `synced: false` might cause data loss on crash.
fix
Use `synchronous: 'FULL'` or omit WAL for maximum safety; WAL with `NORMAL` is faster but less durable.
affects: >=0.8.0
Errors
Common errors & fixes
Cannot find module 'prisma-adapter-bun-sqlite' or its corresponding type declarations.
Package not installed or Bun version too old (pre-1.3.0).
fix
Run `bun add prisma-adapter-bun-sqlite` and ensure Bun >=1.3.0.
TypeError: Class extends value undefined is not a constructor or null.
Importing PrismaClient from '@prisma/client' instead of generated path.
fix
Import PrismaClient from the generated output file (e.g., './prisma/generated/client').
Error: The database file cannot be opened. Does it exist?
The SQLite file path in `url` is incorrect or the directory does not exist.
fix
Ensure the path points to an existing file or use `:memory:` for in-memory. For file: paths, create the directory first.
PrismaClientInitializationError: Invalid `prisma.user.findMany()` invocation: ... "Raw" is not supported
Using a raw query method with an adapter that doesn't support it (this adapter does support raw queries, but error may occur if adapter not properly configured).
fix
Ensure `PrismaClient` is correctly instantiated with `{ adapter }` and the generated client is up-to-date (`bunx prisma generate`).
Upgrade
Version history
0.8.0latest on npm
Audit
Dependencies
@prisma/clientrequiredPeer dependency required to use the PrismaClient constructor with adapter
Agent activity
6 hits · last 30 days
node
6
Resources
prisma-adapter-bun-sqlite — npm install prisma-adapter-bun-sqlite · libregistry