Is there a way to pass a transaction (tx) into Better Auth APIs?
I’d like to create a custom signup flow without relying on the built-in beforeSignUp or afterSignUp hooks. I want to build a separate API endpoint so that I can fully customize the request and response structure.
My goal is to perform some custom database operations (for example, creating basic data) before calling the Better Auth signup logic — and wrap everything inside a single transaction for consistency.
typescriptreturn prisma.$transaction(async (tx) => { // custom pre-signup logic await tx.userBase.create({ ... }); // ideally, I want to call Better Auth signup using this transaction await auth.api.signUpEmail(...);});
typescriptreturn prisma.$transaction(async (tx) => { // custom pre-signup logic await tx.userBase.create({ ... }); // ideally, I want to call Better Auth signup using this transaction await auth.api.signUpEmail(...);});
Is there any way to pass the Prisma transaction (tx) into Better Auth APIs, so that if any step fails (either my pre-signup logic or Better Auth’s internal user creation), the whole process rolls back?