Leave Organization
https://www.better-auth.com/docs/concepts/hooks
Hi everyone,
I'm currently integrating BetterAuth and have run into a challenge related to the "Leave Organization" functionality.
While there are helpful hooks like beforeDelete for organizationDeletion, I noticed there's no dedicated custom hook for when a member leaves an organization. I want to perform cleanup operations in my own database (e.g., removing related records from associated tables), but I can’t find a direct way to hook into that event.
I attempted to use global hooks as shown in the documentation image, but I'm unable to access important context like the userId, memberId, or even the sessionId when the leave event is triggered. Without this, it’s difficult to clean up associated data reliably.
Has anyone else encountered this, or is there a recommended approach to handle this use case? Is there a workaround or best practice for tracking and handling organization leave events?
Any help or guidance would be greatly appreciated — thanks in advance!
https://www.better-auth.com/docs/concepts/hooks
Hooks | Better Auth
Better Auth Hooks let you customize BetterAuth's behavior





3 Replies
@admin
@daveycodez
Due to above issue, we have been stuck for giving client demo. Please help me asap.
have you tried creating custom api route that would trigger the
auth.api.leaveOrganization
, and then pass the required data from the user to the endpoint@Rookie Can you go through this.
If any issue arise, then consult with @sebastian