Prisma + Better Auth + Turborepo Issue 🤔

Hey everyone! Here's what's happening:

The Setup
  • Using a Turborepo with Next.js
  • Prisma schema is in a separate package (packages/database)
  • Using Better Auth for authentication
  • Everything works perfectly in development (pnpm dev)
The Problem

When I build the app (pnpm build, on my local machine), Better Auth throws errors saying it can't find models in the database (like session doesn't exist), even though:
  • The database is the same one I use in development
  • The tables definitely exist (since dev mode works fine)
  • All the proper build dependencies are set up in turbo.json (afaik)
any idea about what might be happening?

Thank you 🙏🏻
Was this page helpful?