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.Install Prisma dependencies
Then install the Prisma CLI (
prisma), Prisma Client (@prisma/client), and the LibSQL adapter as dependencies.terminal
Initialize Prisma with SQLite
Use the Prisma CLI with This creates a basic schema. Open
prisma/schema.prisma
bunx to initialize the schema and migration directory. This guide uses an in-memory SQLite database.terminal
prisma/schema.prisma, update the generator block to use the Rust-free client with the bun runtime, and add a User model.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
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
Initialize Prisma Client with LibSQL
Create a new file
prisma/db.ts
prisma/db.ts that initializes the PrismaClient with the LibSQL adapter.Create a test script
Write a script that creates a new user, then counts the users in the database.
index.ts
Prisma is now set up with Bun. See the Prisma docs as you build out your application.