Getting Started
The ConnectyCube Web Chat Widget is designed to simplify the process of adding chat functionality to your Web apps. This widget offers an out-of-the-box solution for embedding chat features - such as instant messaging, user presence, and file sharing - without the overhead of building a complete chat system from scratch. Key benefits include:
- Easy integration: plug the widget into your existing Web projects.
- Customizable interface: adjust the look and feel to match your brand.
- Real-time messaging: leverage ConnectyCube’s reliable backend for instant communication.
- Responsive design: works seamlessly on both desktop and mobile devices.
- Modular and extensible: adapt the widget to your unique requirements.
Code samples
Section titled “Code samples”See chat widget code samples as a reference for faster integration.
Installation
Section titled “Installation”# npmnpm install --save @connectycube/chat-widget
# yarnyarn add @connectycube/chat-widgetAdd the following scripts on your html page somewhere in head element:
<script src="https://unpkg.com/react@18/umd/react.production.min.js" crossorigin></script><script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js" crossorigin></script><script src="https://unpkg.com/connectycube@4/dist/connectycube.min.js"></script><script src="https://unpkg.com/@connectycube/chat-widget@latest/dist/index.umd.js"></script># npmnpm install --save @connectycube/chat-widget-angular
# yarnyarn add @connectycube/chat-widget-angularAs this component uses wrapped @connectycube/chat-widget, install types for React and ReactDOM as devDependencies:
# npmnpm install --save-dev @types/react @types/react-dom
# yarnyarn add --dev @types/react @types/react-domDisplay widget
Section titled “Display widget”Before you start
Section titled “Before you start”Before you start, make sure:
- You have access to your ConnectyCube account. If you don’t have an account, sign up here.
- An app created in ConnectyCube dashboard. Once logged into your ConnectyCube account, create a new application and make a note of the app credentials (App ID and Auth Key) that you’ll need for authentication.
Import and place the following component in your app:
import ConnectyCubeChatWidget from "@connectycube/chat-widget";
...
<ConnectyCubeChatWidget appId="123" authKey="11111111-2222-3333-4444-55555555" userId="45" userName="Samuel" showOnlineUsersTab={false} splitView={true}/>
// userName - how other users will see your user name// userId - a User Id from your systemSee chat widget code samples as a reference for faster integration.
Detailed YouTube guide how to add ConnectyCube Chat Widget to React app:
React version support
Section titled “React version support”Since v0.35.0, the default build of the widget targets React 19 and is provided as an ESM module. For React 18 projects, use the dedicated ESM-only build:
// v0.35.0 and later:import ConnectyCubeChatWidget from '@connectycube/chat-widget'; // default: React 19import ConnectyCubeChatWidget from '@connectycube/chat-widget/react19'; // explicit React 19 buildimport ConnectyCubeChatWidget from '@connectycube/chat-widget/react18'; // dedicated React 18 build
// v0.34.0 and earlier:import ConnectyCubeChatWidget from '@connectycube/chat-widget'; // default: React 18import ConnectyCubeChatWidget from '@connectycube/chat-widget/react19'; // React 19 buildVanilla JS
Section titled “Vanilla JS”Place the following script in your app:
<!doctype html><html lang="en"> <head> <!-- ... --> </head> <body> <!-- ... --> <!-- @connectycube/chat-widget - start --> <script src="https://unpkg.com/react@18/umd/react.production.min.js" crossorigin></script> <script src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js" crossorigin></script> <script src="https://unpkg.com/connectycube@4/dist/connectycube.min.js"></script> <script src="https://unpkg.com/@connectycube/chat-widget@latest/dist/index.umd.js"></script> <script> const chatWidgetContainer = document.createElement('div'); chatWidgetContainer.id = 'ConnectyCube_chat-widget'; document.body.appendChild(chatWidgetContainer); const props = { appId: 123, authKey: '11111111-2222-3333-4444-55555555', userId: '45', // a User Id from your system userName: 'Samuel', // how other users will see your user name showOnlineUsersTab: false, splitView: true, }; ReactDOM.createRoot(chatWidgetContainer).render(React.createElement(ConnectyCubeChatWidget, props)); </script> <!-- @connectycube/chat-widget - end --> </body></html>