Skip to main content
Note — Prisma’s dynamic subcommand loading system currently requires npm to be installed alongside Bun. This affects certain CLI commands like prisma init, prisma migrate, etc. Generated code works perfectly with Bun using the new prisma-client generator.
1

Create a new project

Prisma works out of the box with Bun. First, create a directory and initialize it with bun init.
terminal
2

Install Prisma dependencies

Then install the Prisma CLI (prisma), Prisma Client (@prisma/client), and the LibSQL adapter as dependencies.
terminal
3

Initialize Prisma with SQLite

We’ll use the Prisma CLI with bunx to initialize our schema and migration directory. For simplicity we’ll be using an in-memory SQLite database.
terminal
This creates a basic schema. We need to update it to use the new Rust-free client with Bun optimization. Open prisma/schema.prisma and modify the generator block, then add a User model.
prisma/schema.prisma
4

Create and run database migration

Then generate and run initial migration.This will generate a .sql migration file in prisma/migrations, create a new SQLite instance, and execute the migration against the new instance.
terminal
5

Generate Prisma Client

As indicated in the output, Prisma re-generates our Prisma client whenever we execute a new migration. The client provides a fully typed API for reading and writing from our database. You can manually re-generate the client with the Prisma CLI.
terminal
6

Initialize Prisma Client with LibSQL

Now we need to create a Prisma client instance. Create a new file prisma/db.ts to initialize the PrismaClient with the LibSQL adapter.
prisma/db.ts
7

Create a test script

Let’s write a script to create a new user, then count the number of users in the database.
index.ts
8

Run and test the application

Let’s run this script with bun run. Each time we run it, a new user is created.
terminal
terminal
terminal

That’s it! Now that you’ve set up Prisma using Bun, we recommend referring to the official Prisma docs as you continue to develop your application.