Skip to main content
Quick Reference for AI Agents & Developers
# 1. Remove old packages
npm uninstall @cometchat-pro/chat @cometchat-pro/calls

# 2. Install new packages
npm install @cometchat/chat-sdk-javascript
npm install @cometchat/calls-sdk-javascript  # if using calls
// 3. Update imports
// Before: import { CometChat } from "@cometchat-pro/chat";
import { CometChat } from "@cometchat/chat-sdk-javascript";

// Before: import { CometChatCalls } from "@cometchat-pro/calls";
import { CometChatCalls } from "@cometchat/calls-sdk-javascript";
Upgrading from v3.x to v4 is straightforward. This guide covers all breaking changes and migration steps.
Complete the SDK Setup for v4 before proceeding with the migration steps below.

What’s New in V4

FeatureV3V4
Package Name@cometchat-pro/chat@cometchat/chat-sdk-javascript
Calls SDK@cometchat-pro/calls@cometchat/calls-sdk-javascript
TypeScript SupportPartialFull
Bundle SizeLargerOptimized
Tree ShakingLimitedFull support

Migration Steps

1

Update Package Dependencies

Remove the old packages and install the new ones:
# Remove old packages
npm uninstall @cometchat-pro/chat @cometchat-pro/calls

# Install new packages
npm install @cometchat/chat-sdk-javascript
npm install @cometchat/calls-sdk-javascript  # If using calls
2

Update Import Statements

Update all import statements throughout your project:
// Before (v3)
import { CometChat } from "@cometchat-pro/chat";

// After (v4)
import { CometChat } from "@cometchat/chat-sdk-javascript";
3

Verify Initialization

The initialization API remains the same:
const appSetting = new CometChat.AppSettingsBuilder()
  .subscribePresenceForAllUsers()
  .setRegion(region)
  .autoEstablishSocketConnection(true)
  .build();

await CometChat.init(appId, appSetting);
4

Test Your Application

Run your application and verify:
  • User authentication works
  • Messages send and receive correctly
  • Real-time listeners fire as expected
  • Calls connect properly (if using Calls SDK)

Find and Replace Guide

Use your IDE’s find and replace to quickly update imports:
FindReplace With
@cometchat-pro/chat@cometchat/chat-sdk-javascript
@cometchat-pro/calls@cometchat/calls-sdk-javascript

Breaking Changes

The following changes may require code updates beyond simple find-and-replace.

Package Scope Change

The package scope changed from @cometchat-pro to @cometchat:
// v3
import { CometChat } from "@cometchat-pro/chat";

// v4
import { CometChat } from "@cometchat/chat-sdk-javascript";

TypeScript Improvements

V4 includes improved TypeScript definitions. If you’re using TypeScript, you may see new type errors that were previously undetected. These are typically beneficial as they catch potential bugs.

Troubleshooting

Ensure you’ve completely removed the old packages:
rm -rf node_modules
rm package-lock.json  # or yarn.lock
npm install
Clear your TypeScript cache and rebuild:
rm -rf dist .tsbuildinfo
npm run build
Ensure both SDKs are updated to v4:
npm list @cometchat/chat-sdk-javascript @cometchat/calls-sdk-javascript

Verification Checklist

After migration, verify these features work correctly:
  • SDK initialization succeeds
  • User login/logout works
  • Send and receive text messages
  • Send and receive media messages
  • Real-time message listeners fire
  • User presence updates work
  • Group operations function correctly
  • Calls connect and disconnect properly (if applicable)

Next Steps