Quick Reference for AI Agents & Developers
Choose Your Integration PathCometChat offers multiple ways to add chat to your application:
| Approach | Best For | Effort |
|---|---|---|
| Widget Builder | Quick embed, minimal coding | No Code |
| UI Kit Builder | Visual customization with code export | Low Code |
| UI Kits | Pre-built components, full control | Code |
| SDK (this guide) | Complete flexibility, custom UI | Code |
| REST API | Server-side integration | Code |
Quick Start
Get up and running in 4 steps:Get Your Credentials
Sign up for CometChat and create a new app. Note your App ID, Region, and Auth Key from the API & Auth Keys section.
Using Next.js, Nuxt, or another SSR framework? CometChat requires browser APIs and won’t work during server-side rendering. Use dynamic imports and client-only directives. See the Framework Integration section for complete setup guides for React, Next.js, Vue, Nuxt, and Angular.
What’s Next?
Setup Guide
Detailed configuration options including SSR support for Next.js and Nuxt.
Key Concepts
Understand users, groups, messages, and how CometChat works.
Send Messages
Send text, media, and custom messages to users and groups.
Receive Messages
Handle real-time messages and fetch message history.
Core Features
Essential messaging capabilities built into the SDK:| Feature | Description | Learn More |
|---|---|---|
| Instant Messaging | Real-time one-on-one and group chat | Send Message |
| Media Sharing | Share images, videos, documents, and files | Media Messages |
| Read Receipts | Know when messages are delivered and read | Delivery & Read Receipts |
| Mark as Unread | Mark messages as unread to revisit later | Mark as Unread |
| Typing Indicators | Show when users are typing | Typing Indicators |
| User Presence | Real-time online/offline status | User Presence |
| Reactions | React to messages with emojis | Reactions |
| Mentions | @mention users in conversations | Mentions |
| Threaded Conversations | Create message threads for organized discussions | Threaded Messages |
| Quoted Replies | Reply to specific messages with context | Quoted Messages |
| Group Chats | Create and manage group conversations | Groups |
| Report Message | Allow users to report inappropriate content | Flag Message |
| Conversation & Advanced Search | Search messages by text, file name, mentions, or mime type | Search Messages |
Extensions
Enhance your chat with these optional features. Enable them from the CometChat Dashboard under Extensions.User Experience
User Experience
| Extension | Description |
|---|---|
| Message Shortcuts | Quick shortcuts for common messages |
| Avatars | Auto-generated avatars for users |
| Link Preview | Rich previews for shared URLs |
| Rich Media Preview | Enhanced previews for media content |
| Thumbnail Generation | Auto-generate thumbnails for images and videos |
| Pin Message | Pin important messages in conversations |
| Save Messages | Save messages for later reference |
| TinyURL | Shorten long URLs automatically |
| Bitly | URL shortening via Bitly integration |
| Voice Transcription | Transcribe voice messages to text |
User Engagement
User Engagement
| Extension | Description |
|---|---|
| Giphy | Send animated GIFs |
| Tenor | Alternative GIF integration |
| Message Translation | Translate messages in real-time |
| Polls | Create polls for group decisions |
| Reminders | Set reminders for messages |
| Stickers | Send stickers in conversations |
| Stipop Stickers | Premium sticker packs via Stipop |
| Emojis | Enhanced emoji support |
Collaboration
Collaboration
| Extension | Description |
|---|---|
| Collaborative Document | Create and share documents in real-time |
| Collaborative Whiteboard | Shared whiteboard for visual collaboration |
Security
Security
| Extension | Description |
|---|---|
| Disappearing Messages | Messages that auto-delete after a set time |
| End-to-End Encryption | Secure message encryption |
Customer Support
Customer Support
| Extension | Description |
|---|---|
| Chatwoot | Connect with Chatwoot for support workflows |
| Intercom | Integrate with Intercom for customer messaging |
AI User Copilot
AI User Copilot
| Feature | Description |
|---|---|
| Conversation Starter | AI-suggested conversation starters |
| Smart Replies | AI-generated reply suggestions |
| Conversation Summary | AI-generated summaries of conversations |
Voice & Video Calling
Add real-time calling capabilities to your app:Ringing Flow
Complete calling experience with incoming/outgoing UI, accept/reject, and notifications.
Direct Call
Start call sessions directly without the ringing flow.
Recording
Record calls for playback or compliance.
Virtual Background
Blur or replace backgrounds during video calls.
AI Features
Leverage AI to enhance your chat experience:AI Moderation
Automatically moderate content for safety
AI Agents
Build AI-powered chat agents
AI Chatbots
Create intelligent chatbot experiences
Framework Guides
React
Integration guide for React applications
Angular
Integration guide for Angular applications
Vue
Integration guide for Vue.js applications
Sample Apps
Explore complete implementations with UI:| Framework | Repository |
|---|---|
| React | javascript-react-chat-app |
| Angular | javascript-angular-chat-app |
| Vue | javascript-vue-chat-app |
Need Pre-Built UI?
If you prefer ready-to-use components instead of building from scratch:React UI Kit
Production-ready React components for chat and calling
Chat Widget
Embeddable chat widget for any website
Complete Working Example
Here’s a production-ready example that initializes CometChat, logs in, sends a message, and listens for responses:Common Errors & Solutions
ERR_INVALID_APP_ID - App ID is invalid
ERR_INVALID_APP_ID - App ID is invalid
Cause: The App ID doesn’t match any app in your CometChat account.Solution:
- Go to CometChat Dashboard
- Select your app → API & Auth Keys
- Copy the exact App ID (case-sensitive)
- Ensure no extra spaces when pasting
ERR_INVALID_AUTH_KEY - Auth Key is invalid
ERR_INVALID_AUTH_KEY - Auth Key is invalid
Cause: Using wrong key type or incorrect key.Solution:
- Use Auth Key (not REST API Key) for client-side login
- Auth Key is for development only; use Auth Tokens in production
- Copy directly from Dashboard → API & Auth Keys
ERR_UID_NOT_FOUND - User does not exist
ERR_UID_NOT_FOUND - User does not exist
Cause: Trying to login with a UID that hasn’t been created.Solution:
- Use test users:
cometchat-uid-1throughcometchat-uid-5 - Or create users via REST API before login
- Check for typos in the UID
ERR_NOT_LOGGED_IN - User is not logged in
ERR_NOT_LOGGED_IN - User is not logged in
Cause: Calling SDK methods before successful login.Solution:
Messages not received in real-time
Messages not received in real-time
Cause: Message listener not registered or registered before login.Solution:
- Register listeners AFTER successful login
- Use unique listener IDs
- Check WebSocket connection:
CometChat.getConnectionStatus() - Ensure
autoEstablishSocketConnection(true)in app settings
CORS errors in browser
CORS errors in browser
Cause: Browser security blocking requests.Solution:
- CometChat handles CORS automatically
- If using a proxy, ensure it forwards headers correctly
- Check browser console for specific blocked URLs
SDK Method Reference
Quick lookup for common operations:| Operation | Method | Returns |
|---|---|---|
| Initialize | CometChat.init(appID, settings) | Promise<boolean> |
| Login (Auth Key) | CometChat.login(uid, authKey) | Promise<User> |
| Login (Auth Token) | CometChat.login(authToken) | Promise<User> |
| Logout | CometChat.logout() | Promise<void> |
| Get Logged-in User | CometChat.getLoggedinUser() | Promise<User|null> |
| Send Text | CometChat.sendMessage(textMessage) | Promise<TextMessage> |
| Send Media | CometChat.sendMediaMessage(mediaMessage) | Promise<MediaMessage> |
| Fetch Messages | messagesRequest.fetchPrevious() | Promise<BaseMessage[]> |
| Fetch Conversations | conversationsRequest.fetchNext() | Promise<Conversation[]> |
| Get User | CometChat.getUser(uid) | Promise<User> |
| Get Group | CometChat.getGroup(guid) | Promise<Group> |
| Connection Status | CometChat.getConnectionStatus() | string |