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.
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?
I’ve read through the documentation, but I couldn’t find any examples or explanations about how transactions are handled internally — https://www.better-auth.com/docs/guides/create-a-db-adapter#transaction
Create a Database Adapter | Better Auth
Learn how to create a custom database adapter for Better-Auth
0 Replies