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 appWhat to doSupported widgets
Expo (recommended)npm install @viafoura/sdk-react-native and prebuildAll of them
Bare React NativeCopy the native bridge code from the bare sample appPreview 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 the RNPackage that registers them,
    and add implementation 'com.viafoura:android:2.1.9' to your app's build.gradle.
  • iOS — the managers under ios/ and ios/sdk/ (RNPreviewComments*, RNChat*,
    RNBell*, RCTAuthService, RCTCommentsService, VFInitializerService,
    RTEEventEmitter) plus the bridging header, and add pod '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

RepositoryWhat it isUse it when
sdk-react-native-expoRecommended. Expo sample app that consumes the published @viafoura/sdk-react-native packageYou are integrating the SDK the recommended way
sdk-react-nativeOlder bare React Native sample with hand-written native bridges in the app itselfYour 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

ExportiOSAndroid
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.

#



Did this page help you?