@amazon-devices/lottie-react-native library extends Lottie React Native to support Lottie animations in React Native for Vega (RNV) apps. You can use this library in both TypeScript and JavaScript RNV projects to run Lottie animations.
You don’t need to install this library separately, as it comes pre-installed with RNV apps. It functions as an autolinking library, connecting to your app at runtime. Remember that compatibility is only guaranteed between the library and its corresponding RNV version.
Amazon recommends updating the library version when you upgrade your RNV version. This practice helps maintain consistency and allows you to use the latest features and improvements.
Installation
To use the package, use the following instructions:- Add the JavaScript library dependency in the
package.jsonfile. Select the tab for your React Native version.
- React Native 0.72
- React Native 0.83
-
Reinstall package-lock.json file using
npm installcommand. - Add your Lottie animation to <app_package_root>/src/js/resources/. Add images for Lottie animation to <app_package_root>/assets/image/.
Examples
You can use Lottie in a declarative way, as shown in the following example.APIs
RNV uses lottie-react-native to add support for Lottie animations and supports the same APIs as lottie-react-native APIs. The@amazon-devices/lottie-react-native library does not support iOS, Android, and Windows-specific props.
Component API
Methods (Imperative API)
As shown in the Examples, you can control the Lottie component in an imperative manner by capturing the component withReact.useRef. The reference provides access to the methods listed below, which you can use to have more fine-grained control over your animation’s behavior.
You can’t invoke any of these methods when the animation is in the same state. For example, you can’t invoke play() while the animation plays.
If you invoke play() with different parameters while the animation plays, the library uses the parameters passed in the most recent invocation.
Exceptions on Vega
The following actions and APIs are not supported on Vega:- Passing a remote asset to ‘source’ with a URI
.lottieformat assetsColorFilters- Test filter - there is no equivalent to
TestFilterIosorTestFilterAndroidon Vega
imageAssetsFolder usage
To use theimageAssetsFolder property in RNV, follow these steps:
- Copy your image assets into [PROJECT FOLDER]/assets/image.
- Create a lottie subfolder Create subfolders for each animation if needed.
-
In the
imageAssetsFolderprop, refer to the folder using its relative path. For example: imageAssetsFolder={‘lottie/animation_1’}.
imageAssetsFolder for images added directly to this folder.
For example, the following path doesn’t require an imageAssetsFolder update: [PROJECT FOLDER]/assets/image/images/img_0.png.
The following example shows a JSON structure for reference.

