> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-rn-guide-message-privately.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Leave A Group

> Leave CometChat groups from JavaScript apps by GUID and stop receiving messages and updates for that group.

## Leave a Group

Use `leaveGroup()` to leave a group.

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    const GUID: string = "GUID";

    CometChat.leaveGroup(GUID).then(
    (hasLeft: boolean) => {
    console.log("Group left successfully:", hasLeft);
    }, (error: CometChat.CometChatException) => {
    console.log("Group leaving failed with exception:", error);
    }
    );

    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    const GUID = "GUID";

    CometChat.leaveGroup(GUID).then(
    hasLeft => {
      console.log("Group left successfully:", hasLeft);
    }, error => {
      console.log("Group leaving failed with exception:", error);
    }
    );
    ```
  </Tab>
</Tabs>

| Parameter | Description                                   |
| --------- | --------------------------------------------- |
| `GUID`    | The GUID of the group you would like to leave |

Once a group is left, the user will no longer receive any updates or messages pertaining to the group.

On success, the method resolves with `true` (boolean).

## Real-time Group Member Left Events

Register a `GroupListener` to receive events when members leave.

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    CometChat.addGroupListener(
      "UNIQUE_LISTENER_ID",
      new CometChat.GroupListener({
          onGroupMemberLeft: (message: CometChat.Action, leavingUser: CometChat.User, group: CometChat.Group) => {
              console.log("User left", { message, leavingUser, group });
          }
      })
    );
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    CometChat.addGroupListener(
      "UNIQUE_LISTENER_ID",
      new CometChat.GroupListener({
          onGroupMemberLeft: (message, leavingUser, group) => {
              console.log("User left", { message, leavingUser, group });
          }
      })
    );
    ```
  </Tab>
</Tabs>

<Warning>
  Always remove group listeners when they're no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.

  ```javascript theme={null}
  CometChat.removeGroupListener("UNIQUE_LISTENER_ID");
  ```
</Warning>

## Missed Group Member Left Events

When fetching message history, leave events appear as [`Action`](/sdk/reference/messages#action) messages with:

* `action` — `"left"`
* `actionBy` — [`User`](/sdk/reference/entities#user) who left
* `actionFor` — [`Group`](/sdk/reference/entities#group) that was left

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Join a Group" icon="right-to-bracket" href="/sdk/javascript/join-group">
    Join public or password-protected groups
  </Card>

  <Card title="Delete a Group" icon="trash" href="/sdk/javascript/delete-group">
    Permanently delete a group
  </Card>

  <Card title="Kick & Ban Members" icon="user-slash" href="/sdk/javascript/group-kick-ban-members">
    Remove or ban members from a group
  </Card>

  <Card title="Retrieve Groups" icon="list" href="/sdk/javascript/retrieve-groups">
    Fetch and filter the list of groups
  </Card>
</CardGroup>
