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
image.png
image.png
image.png
image.png
image.png
Better Auth Hooks let you customize BetterAuth's behavior
Was this page helpful?