Adding Rive to Expo
Rive React Native Expo
This article is out of date! Find the new version here.
To enable your Expo application to run Rive animations you'll need to include the native Android and iOS libraries.
To achive this you can make use of development builds or by generating the native projects with prebuild. A development build can be seen as your own version of the Expo Go client that includes custom native libraries. We suggest reading Expo's documentation for more information.
Setup
This guide will demonstrate how you can make use of prebuild to generate the required native code.
Start by creating a new expo app (or use an existing project):
Add the Rive React Native package:
Add a Rive animation to a view:
Running npx expo start
will not work as Expo Go does not include the native libraries needed to run Rive. If you were to run this command you'll see the following error:
Invariant Violation: requireNativeComponent: "RiveReactNativeView" was not found in the UIManager.
Before running your app, you first need to generate the iOS and Android native projects to take ownership of them. You can do this by running npx expo prebuild
, or npx expo run:[ios|android]
(which will run prebuild
automatically).
npx expo run:android
requires Android Studio and the Android SDK to be installed. See the setup environment guide.npx expo run:ios
requires Xcode (macOS only) installed on your computer. See the setup environment guide.
Generate the build folders for both Android and iOS:
You'll be prompted to enter an Android package and iOS Bundle Identifier.
This command will generate android
and ios
build folders in your project directory. These projects allow you to configure your iOS and Android application as you would for a traditional native application.
You may get the following error:
Something went wrong running pod install in the ios directory.
Which is likely due to the minimum target iOS version not being high enought.
Ensure that your apps minimum iOS version is at least 14.0
(this is the minimum version that Rive iOS supports). Open ios/Podfile
and look for the platform :ios
version. It should look something like this:
Change 13.0
to 14.0
:
You can now run on iOS:
and Android:
Local Assets
The example above demonstrates how to load a riv
file as a network asset. To load files from the asset bundle they need to be included in Android Studio and XCode as assets, see Loading in Rive Files.
You can also see this Github Issue for an alternative approach to load assets.
Last updated