AI Integration Quick Reference
AI Integration Quick Reference
Prerequisites
Get your credentials from the CometChat Dashboard:
- App ID
- Region
- Auth Key (for development)
Installation
Package Manager
CDN
CometChat is available as a global variable.
Initialization
Theinit() method initializes the SDK and must be called before any other CometChat method. Call it once at app startup, typically in your entry file (index.js, main.js, or App.js).
- TypeScript
- JavaScript
APP_ID and APP_REGION with your credentials from the Dashboard.
Parameters
AppSettings Options
Presence Subscription
Choose how to subscribe to user presence (online/offline status):WebSocket Connection
By default, the SDK manages WebSocket connections automatically. To manage them manually:Session Storage
Use session storage instead of local storage (data clears when browser closes):SSR Compatibility
The CometChat SDK requires browser APIs (window, WebSocket) and cannot run on the server. For SSR frameworks, initialize the SDK only on the client side.
- Next.js
- NuxtJS
- Ionic/Cordova
Import the SDK dynamically in
useEffect:Next Steps
Authentication
Log in users with Auth Key or Auth Token
Send Messages
Send your first message