Skip to main content
Version: v5

Getting Started

The Basics section of this documentation introduces the fundamentals of Stream Chat for React Native. It will cover installing Stream Chat within your project, give you some troubleshooting tips, and provide an overview of what is possible using the library. This should be considered a primer before delving into the UI and Core Components or Customization sections.

Installation#

Your environment should be setup and a project created prior to beginning the installation.

Add Required dependencies#

Install the required packages in your React Native project.

  yarn add stream-chat-react-native

Stream Chat has a number of peer dependencies that are required to take advantage of all of the out of the box features. It is suggested you follow the install instructions for each package to ensure it is properly setup. Most if not all of the required packages now support auto-linking so setup should be minimal. Those with known additional steps have been noted.

yarn add @react-native-camera-roll/camera-roll @react-native-community/netinfo @stream-io/flat-list-mvcp react-native-document-picker react-native-fs react-native-gesture-handler react-native-image-crop-picker react-native-image-resizer react-native-reanimated react-native-svg

For iOS on a Mac install the pods npx pod-install ios.

Version compatibilities#

To be able to use the Stream Chat React Native SDK, a few dependencies must meet the following version requirements:

react-nativestream-chat-react-native (min required)react-native-reanimated (min required)
0.705.3.12.10.0
0.694.13.02.9.1
0.684.11.02.7.0
0.674.2.02.4.0
0.663.9.02.2.3
0.653.9.02.2.1
0.643.6.22.2.0
0.633.0.02.2.0

Platform compatibilities#

We only support Android and iOS as platforms for the React Native SDK. We do not support Web currently, but this is in our backlog, and we plan to take this up in the future. As an alternative, you can use Stream's React SDK for Web. The React SDK follows the same API and Component convention and is very similar to the React Native SDK.

Additional Steps#

For some of the packages listed below, there are additional steps required to setup the package:

  • react-native-reanimated - additional installation steps

    Add Reanimated's babel plugin to your babel.config.js:

      module.exports = {
    ...
    plugins: [
    ...
    'react-native-reanimated/plugin',
    ],
    };
  • react-native-gesture-handler - additional installation steps

    RNGH requires the package to be imported at the top of the entry file before anything else, this is usually your App.js or index.js file.

    import 'react-native-gesture-handler';
    import { AppRegistry } from 'react-native';

    import App from './App';
    import { name as appName } from './app.json';

    AppRegistry.registerComponent(appName, () => App);

    Also wrap your entry point with <GestureHandlerRootView> or gestureHandlerRootHO

    import { GestureHandlerRootView } from 'react-native-gesture-handler';
    import { OverlayProvider } from 'stream-chat-react-native';

    export default function App() {
    return (
    <GestureHandlerRootView>
    <OverlayProvider>{/* Your app code goes here */}</OverlayProvider>
    </GestureHandlerRootView>
    );
    }

    Please take a look at our Example Application for reference.

  • react-native - additional installation steps

  • react-native-image-crop-picker - additional installation steps

  • react-native-camera-roll - additional installation steps

note

If you are planning to use file picker functionality, make sure you enable iCloud capability in your app - Enable iCloud capability

Add Optional Dependencies#

Video playing support#

Install react-native-video in your React Native project.

Available in stream-chat-react-native >= v4.7.0

Installing this package allows you to play the video files/attachments in the chat. Otherwise by default, video files will be opened in default browser of the device.

yarn add react-native-video

We require exoplayer to be the media player on Android. To make react-native-video to use exoplayer, add the following in android/settings.gradle:

include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer')

Sharing attachments#

Install react-native-share in your React Native project.

Installing this package will allow your users to share attachments from the gallery using the native sharing interface on their devices.

yarn add react-native-share

Haptic feedback#

Install react-native-haptic-feedback in your React Native project.

Installing this package will enable haptic feedback when scaling images in the image gallery if the scaling hits the higher or lower limits for its value.

yarn add react-native-haptic-feedback

Copying messages#

Install @react-native-clipboard/clipboard to be able to copy messages to the clipboard.

yarn add @react-native-clipboard/clipboard

AndroidX Support#

AndroidX is a major step forward in the Android ecosystem, and the old support library artifacts are being deprecated. For 0.60, React Native has been migrated over to AndroidX. This is a breaking change, and your native code and dependencies will need to be migrated as well.

(Reference: https://facebook.github.io/react-native/blog/2019/07/03/version-60#androidx-support)

Dependencies such as react-native-document-picker, react-native-gesture-handler, and react-native-reanimated don't have AndroidX support. But an awesome tool named jetifier is quite useful to patch these dependencies with AndroidX support.

Expo Installation#

Stream Chat for React Native is set up for parity on Expo, expo requires a different set of dependencies than bare React Native, in your project directory run.

Add Required Dependencies#

expo install stream-chat-expo
expo install @react-native-community/netinfo expo-document-picker expo-file-system expo-haptics expo-image-manipulator expo-image-picker expo-media-library expo-sharing react-native-gesture-handler react-native-reanimated react-native-svg

Additional Steps#

For some of the packages listed below, there are additional steps required to setup the package:

  • react-native-reanimated - additional installation steps

    Add Reanimated's babel plugin to your babel.config.js:

      module.exports = {
    ...
    plugins: [
    ...
    'react-native-reanimated/plugin',
    ],
    };
  • react-native-gesture-handler - additional installation steps

    RNGH requires the package to be imported at the top of the entry file before anything else, this is usually your App.js or index.js file.

    import 'react-native-gesture-handler';
    import { AppRegistry } from 'react-native';

    import App from './App';
    import { name as appName } from './app.json';

    AppRegistry.registerComponent(appName, () => App);

    Also wrap your entry point with <GestureHandlerRootView> or gestureHandlerRootHO

    import { GestureHandlerRootView } from 'react-native-gesture-handler';
    import { OverlayProvider } from 'stream-chat-react-native';

    export default function App() {
    return (
    <GestureHandlerRootView>
    <OverlayProvider>{/* Your app code goes here */}</OverlayProvider>
    </GestureHandlerRootView>
    );
    }

Add Optional Dependencies#

Video playing support#

Install expo-av in your React Native project.

Available in stream-chat-expo >= v4.7.0

Installing this package allows you to play the video files/attachments in the chat. Otherwise by default, video files will be opened in default browser of the device.

expo install expo-av

Copying messages#

Install expo-clipboard to be able to copy messages to the clipboard.

expo install expo-clipboard

Did you find this page helpful?