Step-by-step guide to migrate from CometChat SDK v3 to v4
Quick Reference for AI Agents & Developers
Report incorrect code
Copy
Ask AI
# 1. Remove old packagesnpm uninstall @cometchat-pro/chat @cometchat-pro/calls# 2. Install new packagesnpm install @cometchat/chat-sdk-javascriptnpm install @cometchat/calls-sdk-javascript # if using calls
Report incorrect code
Copy
Ask AI
// 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.
# Remove old packagesnpm uninstall @cometchat-pro/chat @cometchat-pro/calls# Install new packagesnpm install @cometchat/chat-sdk-javascriptnpm install @cometchat/calls-sdk-javascript # If using calls
2
Update Import Statements
Update all import statements throughout your project:
Chat SDK
Calls SDK
Report incorrect code
Copy
Ask AI
// Before (v3)import { CometChat } from "@cometchat-pro/chat";// After (v4)import { CometChat } from "@cometchat/chat-sdk-javascript";
Report incorrect code
Copy
Ask AI
// Before (v3)import { CometChatCalls } from "@cometchat-pro/calls";// After (v4)import { CometChatCalls } from "@cometchat/calls-sdk-javascript";
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.