Skip to main content
This section covers everything you need to get the CometChat JavaScript SDK running in your application.

Prerequisites

RequirementVersion
npm8.x or above
Node.js16 or above
You’ll also need your credentials from the CometChat Dashboard:
  • App ID
  • Region
  • Auth Key (for development)

Setup Steps

1

Install the SDK

Add the CometChat SDK to your project via npm or CDN. See Installation.
2

Initialize CometChat

Configure and initialize the SDK with your App ID and Region. See Initialization.
3

Authenticate users

Log in users to start sending and receiving messages. See Authentication.

Framework Guides

Using an SSR framework? The SDK requires browser APIs and needs client-side initialization:

Next.js

Dynamic imports with useEffect

NuxtJS

Client-side mounted hook

Ionic/Cordova

Direct SDK usage
Migrating from V3 to V4? Your existing app can be migrated — no need to create a new one. See Upgrading from V3.

Quick Reference

# Install
npm install @cometchat/chat-sdk-javascript
import { CometChat } from "@cometchat/chat-sdk-javascript";

// Initialize
const appSettings = new CometChat.AppSettingsBuilder()
  .setRegion("REGION")
  .subscribePresenceForAllUsers()
  .build();

await CometChat.init("APP_ID", appSettings);

// Login
await CometChat.login("UID", "AUTH_KEY");

Pages in This Section

Installation

Add the SDK via npm or CDN

Initialization

Configure and initialize the SDK

SSR Compatibility

Next.js, Nuxt, and Ionic setup

Authentication

Log in users with Auth Key or Token