Overview
useLeaveSpace returns a callable function for leaving a space (DELETE /spaces/:spaceId/members/me). The user’s membership record is removed. The space’s owner (its userId: the creator of a top-level space, the root space’s creator for a sub-space) can’t leave (409 space/owner-cannot-leave).
When using
SpaceProvider, call leaveSpace from useSpace — it then fetches the space again, so the space’s memberPermissions and member count reflect the change.Usage Example
Parameters
Returns
Promise<void>: resolves with nothing once the user has left. To read what the user may still do in the space, as a non-member, fetch the space again: its memberPermissions describe them. leaveSpace from useSpace does this for you.
