npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

prisma-sqlite-bun-adapter

v1.0.0-alpha1

Published

Prisma 7 driver adapter backed by Bun's built-in bun:sqlite

Readme

prisma-sqlite-bun-adapter

A Prisma 7 driver adapter backed by Bun's built-in bun:sqlite.

Prisma 7 requires a driver adapter for every datasource, and both official SQLite adapters depend on native modules that Bun cannot load — better-sqlite3 is rejected by Bun outright. This package closes that gap using the SQLite driver Bun already ships, so there is nothing to compile and no native dependency.

Install

bun add prisma-sqlite-bun-adapter

Requires Bun ≥ 1.2.17 and @prisma/client 7.x.

📖 Full documentation — guides and an API reference generated from the source.

Usage

import { PrismaBunSQLite } from 'prisma-sqlite-bun-adapter'
import { PrismaClient } from './generated/prisma/client'

const adapter = new PrismaBunSQLite({ url: 'file:./dev.db' })
const prisma = new PrismaClient({ adapter })

Your schema needs no url — Prisma 7 takes connection details from the adapter at runtime and from prisma.config.ts for CLI commands:

datasource db {
  provider = "sqlite"
}

Bring your own connection

Pass a Database you opened yourself to share it with non-Prisma code, load an extension, or set custom flags:

import { Database } from 'bun:sqlite'

const database = new Database('./dev.db', { strict: true })
const adapter = new PrismaBunSQLite({ database })

The adapter will not close a connection you supplied, and will not apply PRAGMAs to it. That handle's lifecycle and configuration stay yours.

Options

new PrismaBunSQLite(
  { url: 'file:./dev.db', readonly: false, create: true, strict: false },
  {
    timestampFormat: 'iso8601', // or 'unixepoch-ms'
    shadowDatabaseUrl: ':memory:',
    statementCacheSize: 100, // 0 disables caching
    pragmas: false, // see below
  },
)

PRAGMAs

Off by default. Passing pragmas enables a sensible set for application use:

new PrismaBunSQLite({ url: 'file:./dev.db' }, { pragmas: {} })
// journal_mode = WAL, foreign_keys = ON, busy_timeout = 5000

Each is overridable ({ pragmas: { journalMode: 'DELETE', busyTimeout: 0 } }). foreign_keys is worth calling out: SQLite leaves it off, which means relations declared in your Prisma schema are not enforced by the database unless you switch it on.

Migrations

prisma migrate dev, db push, and db pull work under Bun with no extra setup. Point prisma.config.ts at your database:

import { defineConfig } from 'prisma/config'

export default defineConfig({
  schema: 'schema.prisma',
  datasource: { url: 'file:./dev.db' },
})
bunx prisma migrate dev --name init

Note that in Prisma 7.9 the CLI connects using this URL and its own SQLite handling — migrations do not route through the adapter. The adapter implements the migration-aware factory (connectToShadowDb) regardless, since that is part of the interface the schema engine consumes.

Differences from @prisma/adapter-better-sqlite3

The test suite runs a shared corpus through both adapters and asserts identical result sets. Three differences are known and deliberate:

| Difference | Why | | --- | --- | | A bound integer read straight back out infers a different column type | The drivers disagree: better-sqlite3 binds every JS number as SQLite REAL, bun:sqlite binds integral ones as INTEGER. Values are unaffected, and so is any column with a declared type, because affinity applies on write. | | BLOBs from columns with no declared type work here | The official adapter throws UnexpectedTypeError on these — its type inference accepts only ArrayBuffer, while better-sqlite3 returns a Buffer. Reported as prisma/prisma#29868. | | A failing BEGIN does not deadlock | The official adapter acquires its transaction mutex before BEGIN and only releases it on success, so a failed BEGIN blocks every later transaction on that adapter. |

Prepared statements are also cached per connection (the official adapter re-prepares on every query), which is the main performance difference.

Development

bun install
bun run typecheck
bun run lint
bun test test/unit
bun test test/differential
bun test test/e2e     # needs: cd test/e2e && bunx prisma generate --config prisma.config.ts
bun test test/cli
bun run fixtures      # regenerate the reference fixture (requires Node)
bun run docs:api      # regenerate docs/api from the source JSDoc

cd site && bun install && bun run dev   # the documentation site

The differential fixture is generated under Node, because Bun cannot load better-sqlite3 in the same process. CI regenerates it and fails on drift, so it cannot decay into a snapshot of this adapter's own behaviour.

License

MIT