Registry / communication / stream-chat-react

stream-chat-react

JSON →
library14.0.1jsnpmunverified

Stream Chat React is the official React component library for building real-time chat UIs using the Stream Chat API. The current stable version is 14.0.1, with frequent patch releases and significant major version updates, such as the recent v14.0.0 which introduced a complete visual and architectural refresh. This SDK provides a comprehensive set of UI components for various chat use cases, including livestream, team collaboration, messaging, and customer support, abstracting away much of the complexity of real-time communication. Key differentiators include its deep integration with the Stream Chat backend service, a highly customizable component system, and a robust API for handling chat functionality, making it a powerful tool for developers needing to implement rich chat experiences quickly.

npm install stream-chat-react
INSTALL
IMPORT
SIG · STREAM-CHAT-REACT
S
stream-chat-react
communicationjavascriptv14.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Chat
import { Chat } from 'stream-chat-react';
const Chat = require('stream-chat-react').Chat;
Primary wrapper component, providing context for the chat client. Use named import.
Channel
import { Channel } from 'stream-chat-react';
import Channel from 'stream-chat-react/Channel';
Provides context for a specific channel. Use named import.
MessageList
import { MessageList } from 'stream-chat-react';
Component to display messages within a channel. Use named import.
MessageInput
import { MessageInput } from 'stream-chat-react';
Component for typing and sending messages. Use named import.
StreamChat (client)
import { StreamChat } from 'stream-chat';
import { StreamChat } from 'stream-chat-react';
The core chat client class is imported from the separate `stream-chat` package, not `stream-chat-react`.
CSS Styles
import 'stream-chat-react/dist/css/index.css';
import 'stream-chat-react/dist/css/v2/index.css';
As of v14.0.0-beta.4, the CSS import path changed. Ensure you're importing from `dist/css/index.css`.

This quickstart demonstrates how to set up the Stream Chat client, connect a user, join a channel, and render a basic chat UI with message list and input components using `stream-chat-react` v14.

import React, { useEffect, useState } from 'react'; import { StreamChat } from 'stream-chat'; import { Chat, Channel, ChannelHeader, MessageList, MessageInput, Window, LoadingIndicator } from 'stream-chat-react'; import 'stream-chat-react/dist/css/index.css'; const API_KEY = process.env.STREAM_API_KEY ?? ''; const USER_ID = process.env.STREAM_USER_ID ?? 'john-doe'; const USER_TOKEN = process.env.STREAM_USER_TOKEN ?? 'YOUR_USER_TOKEN'; // Generate this on your backend const client = StreamChat.getInstance(API_KEY); function App() { const [channel, setChannel] = useState(null); useEffect(() => { async function initChat() { if (!API_KEY || !USER_ID || !USER_TOKEN) { console.error('Please provide STREAM_API_KEY, STREAM_USER_ID, and STREAM_USER_TOKEN environment variables.'); return; } try { await client.connectUser( { id: USER_ID, name: USER_ID, image: `https://getstream.io/random_png/?id=${USER_ID}&name=${USER_ID}`, }, USER_TOKEN, ); const newChannel = client.channel('messaging', 'react-chat-demo', { name: 'React Chat Tutorial', members: [USER_ID, 'other-user-id'], // Add other users you want in the channel }); await newChannel.watch(); setChannel(newChannel); } catch (error) { console.error('Failed to connect or join channel:', error); } } initChat(); return () => { client.disconnectUser(); }; }, []); if (!channel) return <LoadingIndicator />; return ( <Chat client={client} theme='messaging light'> <Channel channel={channel}> <Window> <ChannelHeader /> <MessageList /> <MessageInput /> </Window> </Channel> </Chat> ); } export default App;
Debug
Known issues
breakingVersion 14.0.0 represents a complete visual and architectural overhaul. It includes a redesigned component system, new message composer, overhauled theming, and significant breaking changes to component APIs, CSS class names, and context wrappers. Refer to the official migration guide.
fix
Consult the v14 migration guide (https://getstream.io/chat/docs/sdk/react/v14/release-guides/upgrade-to-v14/) for detailed instructions on updating your application code and styling.
affects: >=14.0.0
breakingThe CSS import path changed in v14.0.0-beta.4. Previously, styles were imported from `stream-chat-react/dist/css/v2/*`. This path no longer works.
fix
Update your CSS import statements from `import 'stream-chat-react/dist/css/v2/index.css';` to `import 'stream-chat-react/dist/css/index.css';`.
affects: >=14.0.0-beta.4
breakingSeveral components were removed in v14.0.0-beta.2, including `ActionsIcon`, `ReactionIcon`, `ThreadIcon`, and `MessageErrorIcon`. These icons are now handled internally or replaced by new component structures.
fix
Remove direct imports and usage of these components. If you were customizing them, investigate the new customization model in v14.
affects: >=14.0.0-beta.2
breakingBreaking changes in `v14.0.0-beta.7` include the removal of `onlySenderCanEdit` from `MessageProps` and the deprecation/removal of several legacy notification text callback props from `Message` (e.g., `getDeleteMessageErrorNotification`).
fix
Update `Message` component props according to the new API. Refactor notification handling as per the v14 documentation.
affects: >=14.0.0-beta.7
gotchaThe `stream-chat-react` library has peer dependencies on specific React versions (`^19.0.0 || ^18.0.0 || ^17.0.0`). Using an incompatible React version can lead to build errors or runtime issues.
fix
Ensure your project's `react` and `react-dom` dependencies match the specified peer dependency range for `stream-chat-react`.
affects: >=13.0.0
gotchaThe core `StreamChat` client must be imported from the `stream-chat` package, not `stream-chat-react`. These are distinct libraries, with `stream-chat-react` building UI on top of `stream-chat`'s client logic.
fix
Always use `import { StreamChat } from 'stream-chat';` for the client instance and `import { ... } from 'stream-chat-react';` for UI components.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'connectUser') OR client.connectUser is not a function
The `StreamChat` client instance from `stream-chat` has not been correctly initialized or passed to the `Chat` component.
fix
Ensure `StreamChat.getInstance(API_KEY)` is called and the resulting client object is passed as the `client` prop to the top-level `<Chat>` component.
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
Incorrect import of `stream-chat-react` components, typically mixing default and named imports or using CommonJS `require()` in an ESM context.
fix
Verify that all `stream-chat-react` components are imported using named imports (e.g., `import { Chat, Channel } from 'stream-chat-react';`).
Failed to compile. Module not found: Error: Can't resolve 'stream-chat-react/dist/css/v2/index.css'
This error occurs after upgrading to `stream-chat-react` v14.0.0-beta.4 or higher, where the CSS import path was changed.
fix
Update the CSS import statement to `import 'stream-chat-react/dist/css/index.css';`.
React Hook "useState" cannot be called inside a callback. React Hooks must be called in a React function component or at the top level of a custom React Hook.
Using React Hooks (like `useState`, `useEffect`) within class components or outside of a functional component's top level, often seen during migration or incorrect component structure.
fix
Ensure all React Hooks are called within functional components or custom hooks and follow the Rules of Hooks.
Upgrade
Version history
14.0.1latest on npm
Audit
Dependencies
@breezystack/lamejsrequiredUsed for audio processing, likely for voice messages.
@emoji-mart/datarequiredEmoji data for the emoji picker component.
@emoji-mart/reactrequiredReact components for the emoji picker.
emoji-martrequiredLegacy emoji picker, potentially for backward compatibility or specific features.
reactrequiredCore React library.
react-domrequiredReact DOM rendering library.
stream-chatrequiredThe underlying JavaScript client for interacting with the Stream Chat API.
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
stream-chat-react — npm install stream-chat-react · libregistry