Better Auth + Multi-Tenant (Separate DBs per tenant)
Hey everyone, Seeking advice on integrating Better Auth in a multi-tenant app where each tenant has its own Postgres DB. My current idea involves using Better Auth's
hooks.before
hooks.before
to dynamically create a
prismaAdapter
prismaAdapter
with the tenant-specific PrismaClient by modifying
ctx.context.adapter
ctx.context.adapter
. Is this a sound approach, or are there better/recommended ways to pass a dynamic Prisma instance to Better Auth per request? Also, any potential pitfalls or edge cases I should be aware of with this method? Open to all suggestions!