Getting started on React Native
Learn how to add the Viafoura conversation and newsfeed SDK to your React Native app.
The Viafoura React Native SDK ships as an Expo module, published to npm as@viafoura/sdk-react-native. It wraps the native iOS and Android SDKs, so every integration needs a native build, the SDK
cannot run in Expo Go or in a JavaScript-only setup.
Choose your integration path
| Your app | What to do | Supported widgets |
|---|---|---|
| Expo (recommended) | npm install @viafoura/sdk-react-native and prebuild | All of them |
| Bare React Native | Copy the native bridge code from the bare sample app | Preview comments, live chat, profile, new comment, notification bell |
Expo - the recommended approach
npm install @viafoura/sdk-react-native
npx expo prebuild --clean
The module autolinks, so there is nothing to register by hand. On iOS, prebuild runs the
pod install for you; if you manage the iOS project yourself, run npx pod-install.
Initialize the SDK once at startup, then render the views you need:
import Viafoura from '@viafoura/sdk-react-native';
await Viafoura.initialize('SITE_UUID', 'your.domain.com', true);Because the SDK contains native code, run the app on a simulator, a device or a
development build, Expo Go cannot load it.
Bare React Native
The package is an Expo module, so an app without Expo cannot install it. Use the bare React
Native sample app as your starting point instead and copy its native bridges into your
project:
- Android — the view managers and services under
android/app/src/main/java/com/sdk/(previewComments/,chat/,profile/,
newComment/,bell/,auth/,comments/) plus theRNPackagethat registers them,
and addimplementation 'com.viafoura:android:2.1.9'to your app'sbuild.gradle. - iOS — the managers under
ios/andios/sdk/(RNPreviewComments*,RNChat*,
RNBell*,RCTAuthService,RCTCommentsService,VFInitializerService,
RTEEventEmitter) plus the bridging header, and addpod 'ViafouraCore', '1.3.5'to your
Podfile. - JavaScript — the wrappers in
src/native/(android/,ios/,auth.ts,comments.ts).
This code becomes part of your app, so you own it and have to keep it in sync with SDK
releases yourself. It also covers only the widgets that were bridged by hand, preview
comments, live chat, profile, new comment and the notification bell. Newer widgets,
including the engagement starter and live questions, are only available through the
Expo module.
Sample applications
| Repository | What it is | Use it when |
|---|---|---|
| sdk-react-native-expo | Recommended. Expo sample app that consumes the published @viafoura/sdk-react-native package | You are integrating the SDK the recommended way |
| sdk-react-native | Older bare React Native sample with hand-written native bridges in the app itself | Your app does not use Expo and you need code to copy |
Running the Expo sample
git clone https://github.com/viafoura/sdk-react-native-expo
cd sdk-react-native-expo
npm install
npx expo prebuild --clean
npm run start
Set your own values in viafouraConfig.ts first, siteUUID, siteDomain, containerId,
articleUrl, articleTitle and articleThumbnailUrl. Requires Node 20.19.4 or newer
(Expo SDK 54 / React Native 0.81).
What the package exposes
| Export | iOS | Android |
|---|---|---|
Viafoura (initialize, login, signup, social/OpenID/cookie login, logout, reset password) | ✅ | ✅ |
PreviewCommentsView | ✅ | ✅ |
ConversationStarterView (engagement starter) | ✅ | ✅ |
ProfileView | — renders an empty view | ✅ |
NewCommentView | — renders an empty view | ✅ |
ViafouraCustomUI (show, hide and recolour individual SDK views) | ✅ | ✅ |
On iOS, PreviewCommentsView and ConversationStarterView present the SDK's own composer
and profile screens natively when the reader taps reply or an author, which is why the
standalone ProfileView and NewCommentView are not needed there.
#
Updated 7 days ago
