Chat application.
npm install chatbortui๐ ChatbortUI โ React Chat Components
ChatbortUI is a lightweight React UI package that provides ready-to-use chat components for private and group messaging using Socket.io.
It is designed to plug into any React application with minimal setup.
โจ Features
๐ฅ User & Group chat support
๐ฌ Real-time messaging (Socket.io)
โ๏ธ Edit messages
๐ Delete messages
โ Minimize / Close chat window
๐งฉ Easy API-based integration
๐ฆ Installation
Install from npm
npm install chatbortui
or
yarn add chatbortui
๐ Local Package Development (Using npm link)
Build & link the package
npm run build
npm link
Use linked package in another project
npm link chatbortui
๐ Components Overview
ChatbortUI provides two main components:
1๏ธโฃ ChatList
Displays:
All users
All groups
Allows:
Selecting a user or group
Creating a new group
Closing the chat list
2๏ธโฃ ChatWindow
Displays:
Chat messages
Allows:
Sending messages
Editing messages
Deleting messages
Private & group chats
Minimize / Close window
๐งฉ Integration Guide
Step 1: Import Components
import { ChatList, ChatWindow } from "chatbortui";
Step 2: ChatList Props
๐ Required Props
Prop Type Description
getAllUsers () => Promise
getAllGroups () => Promise
onSelectChat (id, type, name) => void Fired when a chat is selected
onClose () => void Close chat list
createGroup (groupData) => Promise
currentUserId string Logged-in user ID
currentUserName string Logged-in username
โ Example Usage
getAllGroups={getGroupsApi}
onSelectChat={handleSelectChat}
onClose={handleToggleChatList}
createGroup={createGroup}
currentUserId={currentUserId}
currentUserName={currentUserName}
getGroupManageUsers={getGroupUsersData}
socket={socket}
assignedUsers={assignedUsers}
/>
Step 3: ChatWindow Props
๐ Required Props
Prop Type Description
chatId string Selected chat ID
chatType "user" | "group" Chat type
approachName string Header display name
getMessages (id, type) => Promise
onClose () => void Close window
onMinimize () => void Minimize window
onEditMessage (id, text) => void Edit message
onDeleteMessage (id) => void Delete message
currentUserId string Logged-in user ID
currentUserName string Logged-in username
SOCKET_URL string Socket.io server URL
โ Example Usage
chatType={currentChat.type}
approachName={currentChat.name}
getMessages={getMessages}
onClose={handleCloseChat}
onMinimize={handleMinimizeChat}
onEditMessage={handleEditMessage}
onDeleteMessage={handleDeleteMessage}
currentUserId={currentUserId}
currentUserName={currentUserName}
SOCKET_URL="http://localhost:3000"
/>
Step 4: Full Integration Example
{showChatList && (
getAllGroups={getGroupsApi}
onClose={handleToggleChatList}
onSelectChat={handleSelectChat}
createGroup={createGroup}
/>
)}
{currentChat && (
chatType={currentChat.type}
approachName={currentChat.name}
getMessages={getMessages}
onClose={handleCloseChat}
onMinimize={handleMinimizeChat}
onEditMessage={handleEditMessage}
onDeleteMessage={handleDeleteMessage}
currentUserId={currentUserId}
currentUserName={currentUserName}
SOCKET_URL="http://localhost:3000"
/>
)}
๐งช Expected API Response Formats
getAllUsers
[
{ "id": "1", "username": "Alice" },
{ "id": "2", "username": "Bob" }
]
getAllGroups
[
{ "id": "101", "groupName": "Developers" }
]
getMessages
[
{
"id": "msg1",
"fromUserId": "1",
"messageText": "Hello!",
"createdAt": "2024-01-01T12:30:00"
}
]
๐ Socket.io Events (Backend Requirement)
Your backend must support the following events:
Receive Message
socket.on("receiveMessage")
Edit Message
socket.on("handleEditMessage")
Delete Message
socket.on("handleDeleteMessage")