Installation
Easily add chat to your app with the React Native SDK.
To install the React Native SDK, you can choose from either of two TalkJS modules, depending on whether you would like to build using Expo managed workflows:
Module | Contains native code | Works with Expo managed workflows |
---|---|---|
@talkjs/react-native | Yes | No |
@talkjs/expo | No | Yes |
The @talkjs/react-native
module allows you to build React Native apps fast. The module contains native code, and supports features that depend on native code.
Because it contains native code, @talkjs/react-native
is not suited for building with Expo managed workflows. If you would like to build React Native apps using Expo managed workflows, you can use @talkjs/expo instead.
Install the React Native SDK into your app from the command line. To ensure that the module can be loaded correctly, make sure also to explicitly install the SDK's peer dependencies, as follows (with either your npm or yarn package manager):
npm:
npm install @talkjs/react-native @notifee/react-native @react-native-community/push-notification-ios @react-native-firebase/app @react-native-firebase/messaging react-native-webview
yarn:
yarn add @talkjs/react-native @notifee/react-native @react-native-community/push-notification-ios @react-native-firebase/app @react-native-firebase/messaging react-native-webview
To import the React Native library into your project, add one of the following statements to your app's code, depending on what module system you are using:
ES6/TypeScript:
import * as TalkjsRn from '@talkjs/react-native';
CommonJS:
const TalkjsRn = require('@talkjs/react-native');
Once you have imported the library, to start using TalkJS in your project, follow the React Native getting started guide.
The @talkjs/expo
module allows you to build React Native apps fast. The module does not contain native code, which means that you can use it to build with Expo managed workflows.
Because it does not contain native code, @talkjs/expo
also does not support features that depend on native code, such as push notifications. To use push notifications with @talkjs/expo
, see: Push notifications.
Install the React Native SDK from the command line, as follows:
expo install @talkjs/expo
To import the React Native library into your project, add one of the following statements to your code, depending on what module system you are using:
ES6/TypeScript:
import * as TalkjsRn from '@talkjs/expo';
CommonJS:
const TalkjsRn = require('@talkjs/expo');
Once you have imported the library, to start using TalkJS in your project, follow the React Native getting started guide.
The @talkjs/expo
module does not support push notifications.
To provide push notifications when building with Expo, you can do one of the following:
- Send push notifications from your own backend, using TalkJS webhooks.
- Switch to @talkjs/react-native, and use an Expo Development build to add custom native code. You can use the hosted Expo Application Services (EAS) Build service for building app binaries for your Expo projects.
- Switch to @talkjs/react-native, and use the Expo Prebuild system to generate native code for your project. You can use prebuilds in combination with the hosted EAS Build service for Expo projects.
Both @talkjs/react-native
and @talkjs/expo
are released in a beta state. This is because currently, the React Native SDK does not yet have all the features that are available in the TalkJS JavaScript SDK. As soon as the React Native SDK parallels the features available in the JavaScript SDK, we will release version 1.0.0 of the packages.
That said, we always maintain backward compatibility, so both packages are stable for production use.