Capxul Docs
HooksOrganizations

useCapxulRemoveMember

Mutation hook for removing a member from an organization — revokes their role and authority.

Removes a member from an organization — revokes their authority: their role and the spend allowances that came with it. The member is identified by their personalSafeAddress, taken from the member's row in useCapxulOrgMembers. To change what a member can do without removing them, use useCapxulAssignRole.

Import

import { useCapxulRemoveMember } from "@capxul/sdk-react";

Usage

"use client";

import type { MemberView, OrgId } from "@capxul/sdk";
import { useCapxulRemoveMember } from "@capxul/sdk-react";

function RemoveMemberButton({
  orgId,
  member,
}: {
  orgId: OrgId;
  member: MemberView;
}) {
  const removeMember = useCapxulRemoveMember(orgId);

  if (member.personalSafeAddress === null) return null;
  const memberSafeAddress = member.personalSafeAddress;

  return (
    <button
      type="button"
      disabled={removeMember.isPending}
      onClick={() => removeMember.mutate({ memberSafeAddress })}
    >
      {removeMember.isPending ? "Removing…" : `Remove ${member.email}`}
    </button>
  );
}

Parameters

orgId

OrgId | undefined

The organization to remove the member from. Accepts undefined so you can wire it to a not-yet-resolved value, but firing the mutation before it resolves rejects with a CapxulError.

The mutation takes a RemoveMemberInput:

FieldTypeDescription
memberSafeAddressAddressThe member's identity key — take it from the member's personalSafeAddress on the MemberView row (that field is null while the member is still pending).

Return type

import { type UseCapxulRemoveMemberReturn } from "@capxul/sdk-react";
// UseMutationResult<void, CapxulError, RemoveMemberInput>

On success there is no payload — data is void; read the updated roster from the refetched member list.

The hook returns TanStack Query's UseMutationResult. The most-used fields:

FieldDescription
mutateFire the mutation (fire-and-forget; pair with onSuccess/onError callbacks).
mutateAsyncFire the mutation and get a Promise of the result. Rejects with a CapxulError on failure.
dataThe mutation result (typed per hook, shown above). undefined until the first success.
errorA CapxulError when the last attempt failed, otherwise null.
isPendingtrue while the mutation is in flight. Use it to disable submit buttons.
resetClear the mutation state (data, error) back to idle.

Mutations do not retry by default. The full field list is in the TanStack Query useMutation reference; see also the TanStack Query integration guide.

Cache behavior

On success this mutation invalidates the org's member list (["capxul", "org", orgId, "members"]), so useCapxulOrgMembers refetches. Other orgs' caches are untouched.

Errors

Failures surface as a CapxulError on error / thrown from mutateAsync — for example when the mutation fires while orgId is still undefined, or when the removal is rejected.

Client method

This hook wraps client.org(orgId).removeMember(input) — the entity-scoped org bundle on the core SDK.

On this page