> ## 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.

# Join A Group

> Learn how to join public, password-protected, and private groups, and receive real-time join events using the CometChat React Native SDK.

<Accordion title="AI Integration Quick Reference">
  ```javascript theme={null}
  // Join a public group
  await CometChat.joinGroup("GUID", CometChat.GROUP_TYPE.PUBLIC, "");

  // Join a password-protected group
  await CometChat.joinGroup("GUID", CometChat.GROUP_TYPE.PASSWORD, "password123");

  // Listen for member joined events
  CometChat.addGroupListener("listener", new CometChat.GroupListener({
    onGroupMemberJoined: (message, joinedUser, joinedGroup) => { }
  }));
  ```
</Accordion>

Join a group to start sending and receiving messages in it. Public groups can be joined freely, password groups require the correct password, and private groups require an admin to add you (no direct join).

## Join a Group

Use `joinGroup()` to join a group.

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

    const password: string = "";
    const groupType: string = CometChat.GROUP_TYPE.PUBLIC;

    CometChat.joinGroup(GUID, groupType, password).then(
      (group: CometChat.Group) => {
          console.log("Group joined successfully:", group);
      }, (error: CometChat.CometChatException) => {
          console.log("Group joining failed with exception:", error);
      }
    ); 
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    const GUID = "GUID";
    const password = "";
    const groupType = CometChat.GROUP_TYPE.PUBLIC;

    CometChat.joinGroup(GUID, groupType, password).then(
    group => {
      console.log("Group joined successfully:", group);
    }, error => {
      console.log("Group joining failed with exception:", error);
    }
    );
    ```
  </Tab>
</Tabs>

| Parameter   | Description                                             |
| ----------- | ------------------------------------------------------- |
| `GUID`      | The GUID of the group to join                           |
| `groupType` | `CometChat.GROUP_TYPE.PUBLIC`, `PASSWORD`, or `PRIVATE` |
| `password`  | Required for password-protected groups                  |

Once joined, you can send and receive messages in the group. CometChat tracks joined groups — you don't need to rejoin each session. Check `hasJoined` on the [`Group`](/sdk/reference/entities#group) object to verify membership.

The method returns a [`Group`](/sdk/reference/entities#group) object with `hasJoined` set to `true`.

## Real-time Group Member Joined Events

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

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

  <Tab title="JavaScript">
    ```javascript theme={null}
    CometChat.addGroupListener(
      "UNIQUE_LISTENER_ID",
      new CometChat.GroupListener({
          onGroupMemberJoined: (message, joinedUser, joinedGroup) => {
              console.log("User joined", { message, joinedUser, joinedGroup });
          }
      })
    );
    ```
  </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 Joined Events

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

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

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Leave a Group" icon="right-from-bracket" href="/sdk/react-native/leave-group">
    Allow members to leave a group
  </Card>

  <Card title="Group Members" icon="users" href="/sdk/react-native/retrieve-group-members">
    Fetch the list of members in a group
  </Card>

  <Card title="Send Messages" icon="paper-plane" href="/sdk/react-native/send-message">
    Send messages to group conversations
  </Card>

  <Card title="Add Members" icon="user-plus" href="/sdk/react-native/group-add-members">
    Programmatically add members to a group
  </Card>
</CardGroup>
