From fea3af6df9ffd6ab6b5803711776a8795d7c1f46 Mon Sep 17 00:00:00 2001 From: Aman Varshney Date: Wed, 19 Nov 2025 16:40:33 +0530 Subject: [PATCH 1/2] Add caalout for bun and sqlite --- .../100-quickstart/200-sqlite.mdx | 18 ++++++++++++++++++ .../200-add-to-existing-project/200-sqlite.mdx | 18 ++++++++++++++++++ .../050-overview/500-databases/500-sqlite.mdx | 17 +++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx b/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx index 550910a297..7dcdbdd727 100644 --- a/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx +++ b/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx @@ -210,6 +210,24 @@ const prisma = new PrismaClient({ adapter }); export { prisma }; ``` +:::tip Using SQLite with Bun +When targeting Bun, use the `@prisma/adapter-libsql` adapter instead of `@prisma/adapter-better-sqlite3` (Bun doesn’t support the native SQLite driver that `better-sqlite3` relies on). Instantiate Prisma Client like so: + +```ts +import 'dotenv/config'; +import { PrismaLibSql } from '@prisma/adapter-libsql'; +import { PrismaClient } from '../generated/prisma/client'; + +const adapter = new PrismaLibSql({ + url: process.env.DATABASE_URL ?? '', +}); + +const prisma = new PrismaClient({ adapter }); + +export { prisma }; +``` +::: + ## 8. Write your first query Create a `script.ts` file to test your setup: diff --git a/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx b/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx index fbdafa6a4d..345428fbf8 100644 --- a/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx +++ b/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx @@ -175,6 +175,24 @@ const prisma = new PrismaClient({ adapter }); export { prisma }; ``` +:::tip Using SQLite with Bun +Bun doesn't support the native SQLite driver that `better-sqlite3` relies on. When targeting Bun, use the `@prisma/adapter-libsql` adapter instead: + +```ts +import 'dotenv/config'; +import { PrismaLibSql } from '@prisma/adapter-libsql'; +import { PrismaClient } from '../generated/prisma/client'; + +const adapter = new PrismaLibSql({ + url: process.env.DATABASE_URL ?? '', +}); + +const prisma = new PrismaClient({ adapter }); + +export { prisma }; +``` +::: + ## 8. Query your database Now you can use Prisma Client to query your database. Create a `script.ts` file: diff --git a/content/200-orm/050-overview/500-databases/500-sqlite.mdx b/content/200-orm/050-overview/500-databases/500-sqlite.mdx index 6235b5d18c..4d9ab5a64a 100644 --- a/content/200-orm/050-overview/500-databases/500-sqlite.mdx +++ b/content/200-orm/050-overview/500-databases/500-sqlite.mdx @@ -66,6 +66,23 @@ const adapter = new PrismaBetterSqlite3({ const prisma = new PrismaClient({ adapter }) ``` +:::tip Using SQLite with Bun +When running Prisma Client on Bun, use the `@prisma/adapter-libsql` driver adapter (Bun doesn't support the native SQLite driver). Instantiate the adapter and pass it to `PrismaClient`: + +```ts +import { PrismaClient } from '../prisma/generated/client'; +import { PrismaLibSql } from '@prisma/adapter-libsql'; + +const adapter = new PrismaLibSql({ + url: process.env.DATABASE_URL ?? '', +}); + +const prisma = new PrismaClient({ adapter }); + +export default prisma; +``` +::: + ### 3. Configure timestamp format for backward compatibility When using driver adapters with SQLite, you can configure how `DateTime` values are stored in the database using the `timestampFormat` option. From 2f5e4356a8975a949b4461d7b685d05f29185520 Mon Sep 17 00:00:00 2001 From: Aman Varshney Date: Wed, 19 Nov 2025 17:02:39 +0530 Subject: [PATCH 2/2] add link to bun docs --- .../02-prisma-orm/100-quickstart/200-sqlite.mdx | 2 +- .../02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx | 3 ++- content/200-orm/050-overview/500-databases/500-sqlite.mdx | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx b/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx index 7dcdbdd727..b5866d0cff 100644 --- a/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx +++ b/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx @@ -211,7 +211,7 @@ export { prisma }; ``` :::tip Using SQLite with Bun -When targeting Bun, use the `@prisma/adapter-libsql` adapter instead of `@prisma/adapter-better-sqlite3` (Bun doesn’t support the native SQLite driver that `better-sqlite3` relies on). Instantiate Prisma Client like so: +When targeting Bun, use the `@prisma/adapter-libsql` adapter instead of `@prisma/adapter-better-sqlite3`. Bun doesn’t support the native SQLite driver that `better-sqlite3` relies on (see the [`node:sqlite` reference](https://bun.com/reference/node/sqlite)). Instantiate Prisma Client like so: ```ts import 'dotenv/config'; diff --git a/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx b/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx index 345428fbf8..506ddbbc4c 100644 --- a/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx +++ b/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx @@ -176,7 +176,7 @@ export { prisma }; ``` :::tip Using SQLite with Bun -Bun doesn't support the native SQLite driver that `better-sqlite3` relies on. When targeting Bun, use the `@prisma/adapter-libsql` adapter instead: +Bun doesn't support the native SQLite driver that `better-sqlite3` relies on (see the [`node:sqlite` reference](https://bun.com/reference/node/sqlite)). When targeting Bun, use the `@prisma/adapter-libsql` adapter instead: ```ts import 'dotenv/config'; @@ -191,6 +191,7 @@ const prisma = new PrismaClient({ adapter }); export { prisma }; ``` + ::: ## 8. Query your database diff --git a/content/200-orm/050-overview/500-databases/500-sqlite.mdx b/content/200-orm/050-overview/500-databases/500-sqlite.mdx index 4d9ab5a64a..6d40fe51ec 100644 --- a/content/200-orm/050-overview/500-databases/500-sqlite.mdx +++ b/content/200-orm/050-overview/500-databases/500-sqlite.mdx @@ -67,7 +67,7 @@ const prisma = new PrismaClient({ adapter }) ``` :::tip Using SQLite with Bun -When running Prisma Client on Bun, use the `@prisma/adapter-libsql` driver adapter (Bun doesn't support the native SQLite driver). Instantiate the adapter and pass it to `PrismaClient`: +When running Prisma Client on Bun, use the `@prisma/adapter-libsql` driver adapter. Bun doesn't support the native SQLite driver that `better-sqlite3` relies on (see the [`node:sqlite` reference](https://bun.com/reference/node/sqlite)). Instantiate the adapter and pass it to `PrismaClient`: ```ts import { PrismaClient } from '../prisma/generated/client';