Skip to main content
Prisma’s dynamic subcommand loading requires npm to be installed alongside Bun. This affects CLI commands such as prisma init and prisma migrate. Generated code works with Bun using the prisma-client generator.
1

Create a new project

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

Use the Prisma CLI with bunx to initialize the schema and migration directory. This guide uses an in-memory SQLite database.
terminal
This creates a basic schema. Open prisma/schema.prisma, update the generator block to use the Rust-free client with the bun runtime, and add a User model.
prisma/schema.prisma
4

Create and run database migration

Generate and run the initial migration. This writes a .sql migration file to prisma/migrations, creates a new SQLite database, and runs the migration against it.
terminal
5

Generate Prisma Client

As the output indicates, Prisma re-generates the Prisma client whenever you run a new migration. The client provides a fully typed API for reading and writing to your database. You can also re-generate it manually with the Prisma CLI.
terminal
6

Initialize Prisma Client with LibSQL

Create a new file prisma/db.ts that initializes the PrismaClient with the LibSQL adapter.
prisma/db.ts
7

Create a test script

Write a script that creates a new user, then counts the users in the database.
index.ts
8

Run and test the application

Run the script with bun run. Each run creates a new user.
terminal
terminal
terminal

Prisma is now set up with Bun. See the Prisma docs as you build out your application.