React chat UI
React chat UI with the backend included
TalkJS gives you three ready React chat UIs: the Inbox, the Chatbox and the conversation list. Tell a component your app ID, who's chatting and which conversation to open, and it shows that conversation from TalkJS with typing indicators, read receipts, unread counts and online status already working.
import { Chatbox } from '@talkjs/react-components';
import '@talkjs/react-components/default.css';
function Chat() {
const appId = '<APP_ID>';
return (
<Chatbox
style={{ width: "400px", height: "600px" }}
appId={appId}
userId="sample_user_alice"
conversationId="sample_conversation"
/>
);
}


The Inbox shows the user's conversations on the left and the selected one on the right. It's the messaging center of your app, usually on its own page. Under 700 pixels wide it switches to a mobile layout.
The Chatbox is the right half of the Inbox: one conversation. It takes up less space, so you can put it next to an order confirmation, a booking or a user profile. The conversation list is the left half, and it works on its own too.
Want a chat that opens from a button? Put a Chatbox in your own popup or drawer and place it wherever your design needs it. Apps on our Classic SDK also have a ready-made Popup.
Add the React chat UI to your app
Install @talkjs/react-components and @talkjs/core, then render the UI you want. This Inbox shows every conversation of a sample user in our test mode, so it runs before you've created any users of your own.
Before you go live, turn on authentication, so that only your users can open their chats.
import { Inbox } from '@talkjs/react-components';
import '@talkjs/react-components/default.css';
<Inbox
appId="<APP_ID>"
userId="sample_user_alice"
/>Customize the React chat UI
Start with props: colorScheme="dark" turns on dark mode, and chatHeaderVisible={false} hides the header. Colors and spacing are CSS. To go further, replace one part, such as the chat header, with your own React component, or start a full theme from the source at github.com/talkjs/themes.
What does a React chat UI need from the server?
Much of what users see in a chat comes from the server. Is the other person typing? Did your message arrive, and did they read it? How many messages are unread, and who’s online? A UI kit draws all of that, but your code has to supply it.
With chatscope’s Chat UI Kit, for example, you pass in each message yourself (its text, time, and sender), and the chat state lives in your code or in their separate use-chat hook.
Our React components get all of that from TalkJS, working from the first render. You also get:
- Reactions, replies, and editing or deleting your own messages, each on or off per user role
- File and image sharing, voice messages, and an emoji picker
- 39 UI languages
- Every message kept on every plan
And when someone misses a message, TalkJS can send an email, a mobile push notification, or an SMS. All three are on every plan; SMS is charged separately.
