How to Use Rive Data Binding & useViewModelInstance in React Native & Expo
By the Charmotion team · Updated · How we write guides

Create a Rive data binding instance with useViewModelInstance, then read and write its properties from your React Native code. In Expo, install @rive-app/react-native and react-native-nitro-modules and run a development build, because Expo Go cannot load the native runtime. Each property you set on the instance updates the animation live.
Key takeaways
- Data binding passes typed values, such as a Number property named mood, between app state and a Rive file.
- Install @rive-app/react-native with react-native-nitro-modules and run a development build, since Expo Go is not supported.
- useViewModelInstance returns instance, isLoading and error, and async: true creates the instance asynchronously.
- Guard on isLoading and error before you write any property.
- Use data binding for values your app owns, and state machine inputs for transitions the animation controls.
What is Rive data binding in React Native?
This guide shows how to use Rive Data Binding in React Native and Expo, from installing the runtime to pushing app state into a running animation. The short version: a designer defines typed properties in the Rive editor, and your app reads and writes them at runtime.
The properties sit on a ViewModel. In the editor, a ViewModel groups fields such as a Number called mood, a String, a Boolean, a Color or a Trigger. In your app, a ViewModelInstance is a live copy of those fields that the runtime binds to a file. Your code changes the instance, and the artboard updates. You do not need to wire one state machine input for every value.
Rive's View Model properties can be Number, String, Boolean, Color, Enum, Trigger, Image, nested View Model or List types, so the same pattern covers a progress bar, a name badge or a list of items. Each runtime uses its own names for these concepts. The web runtime has a viewModel(path) method and a viewModelInstance getter, while React Native uses a hook.
The main difference from a plain state machine setup is that you pass a file and get an instance back. The animation and your React state can then share one source of truth. For the state machine side of the same idea, read Lottie vs Rive state machines and data binding.
How do you install Rive in an Expo app?
The React Native runtime includes native code. It is not compatible with Expo Go, so you need a development build. The recommended package is @rive-app/react-native, which replaces the older rive-react-native package, and it depends on react-native-nitro-modules.
Check these minimums before you start:
| Requirement | Minimum |
|---|---|
| React Native | 0.78 |
| Expo SDK (Expo projects) | 53 |
| iOS | 15.1 |
| Android SDK | 24 |
| Xcode | 16.4 |
| JDK | 17 |
- Install the development client:
npx expo install expo-dev-client - Install the runtime and its Nitro dependency:
npx expo install @rive-app/react-native react-native-nitro-modules - Build and run a development build on a simulator or device, then open that build instead of Expo Go.
In a bare React Native project, use the npm command from Rive's docs, npm install @rive-app/react-native react-native-nitro-modules, and follow the native setup on that page. The steps differ by project, so the Expo guide is not a substitute for it.
If you are starting from a splash screen, animated splash screens in Expo and React Native covers the launch-specific setup.
How does useViewModelInstance create an instance?
The useViewModelInstance hook takes a Rive file and an options object. It returns instance, isLoading and error. Pass async: true to create the instance asynchronously. The hook can also create an instance from a ViewModel or from a RiveViewRef, which helps when a view already exists.
const { instance, isLoading, error } = useViewModelInstance(riveFile, { async: true });
if (error || isLoading || !instance) return null;The riveFile comes from useRiveFile. That hook can load a file from a remote URL, from a native asset bundle resource name, or from an ArrayBuffer. A remote URL lets you replace an animation without shipping a new build. A bundled file works offline from the first launch, which suits splash screens and onboarding.
The options object is where you choose which ViewModel or instance to bind. The data binding page on rive.app lists the exact option keys, so copy them from there rather than from older forum snippets.
The hook is for the React Native runtime. If your React app runs in a browser with the web runtime, the setup differs. The walkthrough in how to use Rive in React and Next.js covers that path.
How do you read and write properties from React state?
Once you have an instance, every property has a type. Write values from the same events that change your UI, such as a route change, a network response or a button press, rather than from timers inside the animation. Keep the mapping from app state to property values in one place.
const MOOD = { idle: 0, happy: 1, wave: 2, thinking: 3, sad: 4, loading: 5, listening: 6, talking: 7, sleeping: 8, attention: 9 };
// When appState changes, look up the number and write it to the Number property named mood on the instance.
const moodValue = MOOD[appState];Use the property accessor for each type, as listed in Rive's data binding docs. The types and typical uses are:
| Type | Typical use | What app code does |
|---|---|---|
| Number | Mood index, progress, counts | Writes a value |
| String | Name, label, title | Writes text |
| Boolean | Show or hide an accent or layer | Writes true or false |
| Trigger | A one-time event | Fires once per event |
| Color | Brand or theme color | Writes a color |
| Enum | A fixed set of options | Writes one option |
Charmotion's character files use this pattern. Its CharacterViewModelMachine has a Number property named mood, and the mood numbers are fixed: idle 0, happy 1, wave 2, thinking 3, sad 4, loading 5, listening 6, talking 7, sleeping 8 and attention 9. Moods blend into each other. Characters have no one-shot triggers, so show a success with happy and an error with sad.
Why does a bound value not update?
Most failures come from a short list of causes. Check them in this order:
- Expo Go. The native runtime does not load in Expo Go. Run a development build.
- Old package. The legacy
rive-react-nativepackage is replaced by@rive-app/react-native. Imports and hooks from older tutorials may not match this pattern. - Version. The async option needs
@rive-app/react-native0.4.18 or later. Update the package ifasyncis ignored. - Instance not ready. Writing to an instance before it exists fails silently in many setups. Return early while
isLoadingis true orerroris set, as in the guard above. - Name mismatch. The name in your code must match the property you created in the editor, including the ViewModel it belongs to.
- Artboard not using the property. A value can be set correctly and still have no visible effect if the animation does not reference that property. Check the artboard in the Rive editor.
If you need to see what is bound, log instance and the property values after the hook returns. Then compare them with the ViewModel in the editor. A mismatch in names or types is the most common cause.
When should you use data binding instead of state machine inputs?
Use data binding when the value comes from your app: a mood index, a progress number, a user's name or a theme color. One ViewModel can carry many of these values, so your code updates them in one place. Use state machine inputs when the animation itself decides what happens next, such as a press that moves between idle and a hover state inside the file.
Both can live in one artboard. Give each value one owner, either the app through data binding or the state machine through its inputs, so two parts of the system do not fight over the same property. For a longer comparison of the two models, see Rive data binding vs state machine inputs.
Lottie is a fair option for simple playback. dotLottie files can also carry state machines, so compare the two formats for your use before choosing. The trade-offs are covered in Lottie vs Rive in React Native and Flutter.
When you ship, test the animation in the development build on a real device. Many issues only show up when the instance loads asynchronously during app launch.
How to use Rive Data Binding in React Native and Expo
- Create a development build. Install expo-dev-client with npx expo install expo-dev-client, then build the app as a development build, because Expo Go cannot load the native runtime.
- Install the runtime. Run npx expo install @rive-app/react-native react-native-nitro-modules. In a bare React Native project, use the npm command and native setup from Rive's React Native docs.
- Define the ViewModel in Rive. In the Rive editor, add a ViewModel with typed properties, such as a Number property named mood, and bind it to the artboard.
- Load the file. Use useRiveFile with a remote URL, a native asset bundle resource name or an ArrayBuffer to get the RiveFile.
- Create the instance. Call useViewModelInstance(riveFile, { async: true }) and return early while isLoading is true or error is set.
- Write values from app state. Map each app state to a property value in one lookup table and write the value when the state changes.
- Test on a device. Run the development build on a real device, confirm the animation responds, and fix any property name that does not match the editor.
Frequently asked questions
Do I need a paid Rive plan to read values in my app?
No. Rive's runtimes are open source and play any .riv file. On Rive's Free plan, exported files play a Rive splash screen, while paid plans export without it. For current plan details, see /guides/is-rive-free-pricing and check rive.app/pricing.
Can a Rive file use data binding and state machine inputs together?
Yes. Give each value one owner: either app code writes it through data binding, or the state machine controls it through its inputs. Sharing one property between both sources makes behavior hard to predict, so decide before you build.
Does useViewModelInstance work in a web browser?
The React Native hook is part of the React Native runtime. The web runtime uses different calls: a viewModel(path) method that returns a ViewModelInstance, a viewModelInstance getter for the bound instance, and getBindableArtboard(name) for artboards that accept a view model.