Installation
Installation and usage of our Stream Chat React Native SDK is simple and involves the following steps:
Prerequisites
First things first, make sure you have set up the development environment for React Native. You can find the official guide here.
For Expo, you can follow this guide.
Add Stream's Chat SDK and its peer dependencies
In order to install the Stream Chat React Native SDK, run the following command in your terminal of choice:
- RN CLI
- Expo
yarn add stream-chat-react-native
npx expo install stream-chat-expo
Stream Chat React Native SDK requires installing some peer dependencies to provide you with a great chat experience. You can run the following command to install them:
- RN CLI
- Expo
yarn add @react-native-camera-roll/camera-roll @react-native-community/netinfo @stream-io/flat-list-mvcp react-native-fs react-native-gesture-handler react-native-image-crop-picker react-native-image-resizer react-native-reanimated react-native-svg
npx expo install @stream-io/flat-list-mvcp @react-native-community/netinfo expo-file-system expo-image-manipulator expo-image-picker expo-media-library react-native-gesture-handler react-native-reanimated react-native-svg
So what did we install precisely?
- RN CLI
- Expo
@react-native-camera-roll/camera-roll
for accessing device gallery.@react-native-community/netinfo
for accessing device gallery.@stream-io/flat-list-mvcp
for bi-directional FlatList support.react-native-fs
to perform file operations like save, delete, etc.react-native-gesture-handler
to handle gestures within the SDK.react-native-image-crop-picker
to capture images to attach them in the message.react-native-image-resizer
to compress image uploads.react-native-reanimated
to compress image uploads.react-native-svg
for SVG support.
expo-media-library
for accessing device gallery.@react-native-community/netinfo
for accessing device gallery.@stream-io/flat-list-mvcp
for bi-directional FlatList support.expo-file-system
to perform file operations like save, delete, etc.react-native-gesture-handler
to handle gestures within the SDK.expo-image-picker
to capture images to attach them in the message.expo-image-manipulator
to compress image uploads.react-native-reanimated
to compress image uploads.react-native-svg
for SVG support.
Optional Dependencies
There are a few optional dependencies that can be added to have more features within the SDK.
- RN CLI
- Expo
react-native-video
for Video and Audio playback support.react-native-share
for Attachment sharing support.react-native-haptic-feedback
for user haptics feedback.@react-native-clipboard/clipboard
for Copy message support.react-native-document-picker
to access device media files.react-native-quick-sqlite
to enable Offline support in the app.
expo-av
for Video and Audio playback support.expo-sharing
for Attachments sharing support.expo-haptics
for user haptics support.expo-clipboard
for Copy message support.expo-document-picker
to access device media files.react-native-quick-sqlite
to enable Offline support in the app.
Additional Steps
Some dependencies require us to make changes to our application for all functionalities to be available.
The most important steps to get started are:
- Add the Babel plugin for
react-native-reanimated
to yourbabel.config.js
file in your application folder:
module.exports = {
presets: [
... // don't add it here :)
],
plugins: [
...
'react-native-reanimated/plugin',
],
};
react-native-reanimated/plugin
has to be listed last.
- After installation, wrap your entry point with
<GestureHandlerRootView>
orgestureHandlerRootHOC
:
import { GestureHandlerRootView } from 'react-native-gesture-handler';
export default function App() {
return <GestureHandlerRootView style={{ flex: 1 }}>{/* content */}</GestureHandlerRootView>;
}
The entry point of your app exists usually either in index.js
or App.tsx
file. In case of navigation with Expo Router v3.x, the entry point is inside app/_layout.js
.
Please also follow the steps mentioned in the links below for corresponding dependencies:
react-native
- additional installation stepsreact-native-image-crop-picker
- additional installation stepsreact-native-cameraroll
- additional installation steps
Now you should be able to run the app on simulator by running following command:
- RN CLI
- Expo
- Android
- iOS
npx pod-install
yarn ios
yarn android
- Android
- iOS
yarn ios
yarn android