react-native-reanimated
React Native Reanimated provides a more comprehensive, low level abstraction for the Animated library API to be built on top of and hence allow for much greater flexibility especially when it comes to gesture based interactions.
With Reanimated, you can easily create smooth animations and interactions that run on the UI thread.
Documentation
For more information about this library and its API, see https://docs.swmansion.com/react-native-reanimated/ in the official Software Mansion documentation.
Installation
- Add the JavaScript library dependency in the package.json file:
"dependencies": {
...
"@amazon-devices/react-native-reanimated": "~2.0.0"
}
```
</div>
2. Add `@amazon-devices/react-native-reanimated` plugin to your babel.config.js:
<p><button id="tYpKuYLt_copy-button" type="button" class="btn btn-default btn-sm copy-button" data-clipboard-action="copy">
<i class="fa fa-files-o" aria-hidden="true"></i> Copy code </button>
<span id="tYpKuYLt_copy-button_tooltip" class="tooltip-for-copy-button">Copied to clipboard.</span></p><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js"></script><script src="https://amzndevresources.com/jekyll/js/clipboardcopy.js"></script>
<div id="tYpKuYLt" markdown="block">
module.exports = {
presets: [
... // don't add it here :)
],
plugins: [
...
'@amazon-devices/react-native-reanimated/plugin',
],
}; ```
-
To clear the Metro bundler cache run the following command:
npm start -- --reset-cache
-
Reinstall the package-lock.json file by running the
npm install
command.
For additonal information and context, see installation in the Software Mansion documentation.
Examples
The following example shows how to run a simple animation in an infinite loop using the withTiming
method.
import React from 'react';
import { StyleSheet, View } from 'react-native';
import Animated, {
useSharedValue,
useAnimatedStyle,
withTiming,
withRepeat,
} from '@amazon-devices/react-native-reanimated';
export default function App() {
const offset = useSharedValue(200);
const animatedStyles = useAnimatedStyle(() => ({
transform: [{ translateX: offset.value }],
}));
React.useEffect(() => {
offset.value = withRepeat(
withTiming(-offset.value, { duration: 1500 }),
-1,
true
);
}, []);
return (
<View style={styles.container}>
<Animated.View style={[styles.box, animatedStyles]} />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
height: '100%',
},
box: {
height: 120,
width: 120,
backgroundColor: '#b58df1',
borderRadius: 20,
},
});
The following example shows how run a spring-based animation using the withSpring
function:
import React from 'react';
import { StyleSheet, View } from 'react-native';
import Animated, {
useSharedValue,
useAnimatedStyle,
withSpring,
withRepeat,
} from '@amazon-devices/react-native-reanimated';
const initialOffset = 200;
export default function App() {
const offset = useSharedValue(initialOffset);
const animatedStyles = useAnimatedStyle(() => ({
transform: [{ translateX: offset.value }],
}));
React.useEffect(() => {
offset.value = withRepeat(withSpring(-offset.value), -1, true);
}, []);
return (
<View style={styles.container}>
<Animated.View style={[styles.box, animatedStyles]} />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
height: '100%',
},
box: {
height: 120,
width: 120,
backgroundColor: '#b58df1',
borderRadius: 20,
},
});
API support
The reanimated library on Vega provides a Turbo Module which adds a support for most of methods listed below.
Animations
method | description |
---|---|
withTiming | withTiming lets you create an animation based on duration and easing. |
withSpring | withSpring lets you create spring-based animations. |
withDecay | withDecay lets you create animations that mimic objects in motion with friction. The animation will start with the provided velocity and slow down over time according to the given deceleration rate until it stops. |
withSequence | withSequence is an animation modifier that lets you run animations in a sequence. |
withRepeat | withRepeat is an animation modifier that lets you repeat an animation given number of times or run it indefinitely. |
withDelay | withDelay is an animation modifier that lets you start an animation with a delay. |
Core
method | description |
---|---|
useSharedValue | useSharedValue lets you define shared values in your components. |
useAnimatedStyle | useAnimatedStyle lets you create a styles object, similar to StyleSheet styles, which can be animated. |
useAnimatedProps | useAnimatedProps lets you create an animated props object which can be animated using shared values. |
useAnimatedRef | useAnimatedRef lets you get a reference of a view. Used alongside measure, scrollTo, and useScrollViewOffset functions. |
useDerivedValue | useDerivedValue lets you create new shared values based on existing ones while keeping them reactive. |
createAnimatedComponent | createAnimatedComponent lets you create an Animated version of any React Native component. Wrapping a component with createAnimatedComponent allows Reanimated to animate any prop or style associated with that component. |
cancelAnimation | cancelAnimation lets you cancel a running animation paired to a shared value. |
Scroll
method | description |
---|---|
scrollTo | scrollTo provides synchronous scroll on the UI thread to a given offset using an animated ref to a scroll view. This allows performing smooth scrolling without lags. |
useScrollViewOffset | useScrollViewOffset allows you to create animations based on the offset of a ScrollView . The hook automatically detects if the ScrollView is horizontal or vertical. |
useAnimatedScrollHandler | useAnimatedScrollHandler is a convenience hook that returns an event handler reference which can be used with React Native's scrollable components. |
Device
method | description |
---|---|
useAnimatedKeyboard | useAnimatedKeyboard allows creating animations based on current keyboard position. |
useAnimatedSensor | useAnimatedSensor lets you create animations based on data from the device's sensors: accelerometer, gyroscope, graviry, magnetic field and rotation. |
useReducedMotion | useReducedMotion lets you query the reduced motion system setting. |
Threading
method | description |
---|---|
runOnJS | runOnJS runOnJS lets you asynchronously run non-workletized* functions that couldn't otherwise run on the UI thread. |
runOnUI | runOnUI lets you asynchronously run workletized functions on the UI thread. |
createWorkletRuntime | createWorkletRuntime lets you create a new JS runtime which can be used to run worklets possibly on different threads than JS or UI thread. |
- workletize
- To convert a JavaScript function into a serializable object which can be copied and ran over on UI thread. Functions marked with "worklet"; directive are automatically picked up and workletized by the Reanimated Babel plugin.
Utilities
method | description |
---|---|
interpolate | interpolate lets you map a value from one range to another using linear interpolation. |
clamp | clamp lets you limit a value within a specified range. |
interpolateColor | interpolateColor maps input range to output colors using linear interpolation. |
getRelativeCoords | getRelativeCoords determines the location on the screen, relative to the given view. |
Advanced APIs
method | description |
---|---|
measure | measure lets you synchronously get the dimensions and position of a view on the screen, all on the UI thread. |
useAnimatedReaction | useAnimatedReaction allows you to respond to changes in a shared value. |
useFrameCallback | useFrameCallback lets you run a function on every frame update. |
useEvent | useEvent is low-level hook returning event handler that will be invoked with native events, which should be used in order to create custom event handler hook like useAnimatedGestureHandler or useAnimatedScrollHandler . |
useHandler | useHandler is low-level hook returning context object and value indicating whether worklet should be rebuilt, which should be used in order to create custom event handler hook like useAnimatedGestureHandler or useAnimatedScrollHandler . |
dispatchCommand | dispatchCommand allows to dispatch command on a native component synchronously from the UI thread. |
setNativeProps | setNativeProps lets you imperatively update component properties. |
The reanimated library on Vega has a few exceptions in terms of API support. This section explains those exceptions.
useAnimatedSensor
is not supported on Vega platform. On FireTV, sensors are not supported so far.useReducedMotion
is not supported on Vega platform. For Vega, a setting for enabling/disabling reduced motion is not available so far.Layout Animations
are not implemented onFabric
yet, so they are not supported on Vega platform.SETs (Shared Element Transitions)
allows you to smoothly transform a component from one screen into a component on another screen. It's experimental feature, which hasn't had a support on Vega yet.
Known Issues on Vega
- Animations that use
withRepeat
stop repeating after fast refresh is used - Style does not update on the animmation after fast refresh is used
Supported versions
Package name | Amazon NPM library version | OSS NPM library version | Vega OS build number | Vega SDK version | Release notes |
---|---|---|---|---|---|
@amazon-devices/react-native-reanimated |
2.0.0+3.5.4 | 3.5.4 | OS 1.1 (201010435950) |
0.19 | Released as a system distributed library. Backward-compatibility checks are not required on the initial release. |
Additional Resources
For information on additonal libraries, see Supported Third-Party Libraries and Services.
Credits
This project has been built and is maintained thanks to the support from Shopify, Expo.io and Software Mansion
Last updated: Sep 30, 2025