{"id":11998,"library":"sendbird","title":"Sendbird Chat SDK v3 for JavaScript","description":"The Sendbird Chat SDK v3 for JavaScript (current stable v3.1.33) facilitates the integration of real-time chat functionalities into client applications, abstracting the complexities of backend infrastructure. It enables core chat features such as user authentication, channel management (open and group channels), message sending and receiving, and event handling. This version is officially deprecated, with v3.1.33 being its final release in August 2023. Sendbird is actively transitioning users to its v4 SDK, which was first released in April 2022 and offers an extended feature set including enhanced WebSocket handling, improved local caching, polls, scheduled messages, and pinned messages. Developers are strongly encouraged to migrate to v4 due to the end of support and future bug fixes for v3.","status":"deprecated","version":"3.1.33","language":"javascript","source_language":"en","source_url":"https://github.com/sendbird/Sendbird-SDK-JavaScript","tags":["javascript","sendbird","sendbird.com","messaging","chat","js","typescript"],"install":[{"cmd":"npm install sendbird","lang":"bash","label":"npm"},{"cmd":"yarn add sendbird","lang":"bash","label":"yarn"},{"cmd":"pnpm add sendbird","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The primary SendBird class is a default export in v3. It also acts as a namespace for many static methods and types.","wrong":"import { SendBird } from 'sendbird'","symbol":"SendBird","correct":"import SendBird from 'sendbird'"},{"note":"Type imports are crucial for TypeScript projects, ensuring correct parameter definitions for message creation.","symbol":"UserMessageParams","correct":"import type { UserMessageParams } from 'sendbird'"},{"note":"While `SendBird` is a default export, certain classes and interfaces are available as named exports or accessed via the `SendBird` instance/namespace. The CommonJS `require` pattern is a common anti-pattern for modern JavaScript/TypeScript projects targeting v3 or later.","wrong":"const SendBird = require('sendbird'); const channel = new SendBird.GroupChannel();","symbol":"GroupChannel","correct":"import { GroupChannel } from 'sendbird'"}],"quickstart":{"code":"import SendBird from 'sendbird';\n\nconst APP_ID = process.env.SENDBIRD_APP_ID ?? 'YOUR_SENDBIRD_APP_ID';\nconst USER_ID = process.env.SENDBIRD_USER_ID ?? 'testuser123';\nconst NICKNAME = process.env.SENDBIRD_USER_NICKNAME ?? 'Test User';\n\nconst sb = new SendBird({\n  appId: APP_ID,\n  modules: [new SendBird.ChannelModule(), new SendBird.MessageModule()]\n});\n\nasync function initializeAndConnect() {\n  try {\n    console.log('Connecting to Sendbird...');\n    const user = await sb.connect(USER_ID);\n    console.log(`Connected as ${user.nickname} (${user.userId})`);\n\n    // Create or get a channel\n    const channelUrl = process.env.SENDBIRD_CHANNEL_URL ?? 'sendbird_open_channel_28653_373c38c116d90a78627e7f77a880949216065548';\n    const channel = await sb.OpenChannel.getChannel(channelUrl);\n    await channel.enter();\n    console.log(`Entered channel: ${channel.name}`);\n\n    // Send a message\n    const messageText = `Hello from SDK v3! Current time: ${new Date().toLocaleTimeString()}`;\n    const params = new sb.UserMessageParams();\n    params.message = messageText;\n    const message = await channel.sendUserMessage(params);\n    console.log('Message sent:', message.message);\n\n    // Disconnect (optional, for cleanup)\n    // await sb.disconnect();\n    // console.log('Disconnected from Sendbird.');\n  } catch (error) {\n    console.error('Sendbird operation failed:', error);\n  }\n}\n\ninitializeAndConnect();","lang":"typescript","description":"This quickstart demonstrates initializing the Sendbird SDK, connecting a user, entering an open channel, and sending a basic user message, including handling environment variables for credentials."},"warnings":[{"fix":"Plan and execute migration to Sendbird Chat SDK v4. Refer to the official Sendbird documentation for migration guides and breaking changes.","message":"Sendbird Chat SDK v3 is officially deprecated as of July 2023, with v3.1.33 being its final release in August 2023. No further updates, bug fixes, or security patches will be provided for this version. Users are strongly advised to migrate to Sendbird Chat SDK v4.","severity":"breaking","affected_versions":">=3.1.33"},{"fix":"Consult the Sendbird Chat SDK v4 documentation and migration guides carefully. Prioritize testing and refactor code incrementally to adapt to the new API paradigms.","message":"Migration from Sendbird Chat SDK v3 to v4 involves significant breaking changes. The API surface, initialization patterns, and underlying architecture have evolved. Direct drop-in replacement is not possible.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Update the `sendbird` package to v3.1.32 or higher. If sticking with an older version, ensure a `localStorage` polyfill is provided for the React Native environment, though upgrading is strongly recommended due to deprecation.","message":"Older versions of Sendbird SDK v3 (prior to v3.1.32) could cause `sb.connect()` to fail in React Native environments due to an unexpected attempt to access the browser's `localStorage` API, which is unavailable in React Native.","severity":"gotcha","affected_versions":"<3.1.32"},{"fix":"Update the `sendbird` package to v3.1.31 or higher. Review your `MessageCollection` event handlers to ensure they gracefully handle potential duplicate or out-of-order message updates if using older versions.","message":"When `localCacheEnabled` was set to `false`, `MessageCollection` in SDK versions prior to v3.1.31 would incorrectly call `onMessagesUpdated()` with old messages upon connection or reconnection, leading to stale UI data.","severity":"gotcha","affected_versions":"<3.1.31"},{"fix":"Update the `sendbird` package to v3.1.24 or higher, which includes a Promise.finally() polyfill. Alternatively, ensure your build toolchain or application code provides a polyfill for `Promise.finally()` if targeting legacy environments.","message":"Applications targeting older browsers or environments that do not natively support `Promise.finally()` (e.g., Internet Explorer 11) would encounter runtime errors if using Sendbird SDK v3 versions prior to v3.1.24, as the SDK lacked an internal polyfill.","severity":"gotcha","affected_versions":"<3.1.24"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Upgrade the `sendbird` package to v3.1.32 or later to resolve the `localStorage` access issue in React Native.","cause":"The Sendbird SDK v3.1.31 or earlier attempted to access `localStorage` in a non-browser environment like React Native, where it is not available.","error":"TypeError: Cannot read properties of undefined (reading 'localStorage')"},{"fix":"Update the `sendbird` package to v3.1.24 or higher, which bundles a `Promise.finally()` polyfill, or include a separate `Promise.finally()` polyfill in your application.","cause":"The Sendbird SDK v3 was used in an environment (e.g., older browser) that lacks native `Promise.finally()` support, and no polyfill was provided.","error":"Uncaught (in promise) TypeError: Cannot read property 'finally' of undefined"},{"fix":"While v3.1.30 had stability improvements related to this, managing `localStorage` size is key. Consider reducing the number of messages cached, clearing old data, or migrating to SDK v4 which has more robust local caching strategies.","cause":"The Sendbird `MessageCollection` is attempting to store more data in `localStorage` than the browser's allocated quota allows.","error":"QuotaExceededError: Failed to execute 'setItem' on 'Storage': Setting the value of 'sendbird_message_collection_key' exceeded the quota."},{"fix":"Upgrade the `sendbird` package to v3.1.28 or later. If unable to upgrade, consider performing file message sending operations outside of Web Workers.","cause":"In Sendbird SDK v3 versions prior to v3.1.28, calling `channel.sendFileMessage()` within a Web Worker environment could lead to failures.","error":"Error: channel.sendFileMessage() failed in web worker context"}],"ecosystem":"npm"}