Documentation Index Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Join a Group
Use joinGroup() to join a group.
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 );
}
);
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 );
}
);
Parameter Description GUIDThe GUID of the group to join groupTypeCometChat.GROUP_TYPE.PUBLIC, PASSWORD, or PRIVATEpasswordRequired 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 object to verify membership.
The method returns a Group object with hasJoined set to true.
Real-time Group Member Joined Events
Register a GroupListener to receive events when members join.
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 });
}
})
);
CometChat . addGroupListener (
"UNIQUE_LISTENER_ID" ,
new CometChat . GroupListener ({
onGroupMemberJoined : ( message , joinedUser , joinedGroup ) => {
console . log ( "User joined" , { message , joinedUser , joinedGroup });
}
})
);
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. CometChat . removeGroupListener ( "UNIQUE_LISTENER_ID" );
Missed Group Member Joined Events
When fetching message history, join events appear as Action messages with:
action — "joined"
actionBy — User who joined
actionFor — Group that was joined
Next Steps
Leave a Group Allow members to leave a group
Retrieve Group Members Fetch the list of members in a group
Send Messages Send messages to group conversations
Add Members Programmatically add members to a group