@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. This library is autolinking, so it connects to your app at runtime. 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, follow these instructions:-
Add the JavaScript library dependency in your application’s package.json:
-
Reinstall package-lock.json file using the
npm installcommand. - Add your Lottie animation to <app_package_root>/src/js/resources/. Add images for the Lottie animation to <app_package_root>/assets/image/.
Examples
You can use Lottie in a declarative way, as shown in the following example.API reference
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 doesn’t support iOS, Android, and Windows-specific props.
Components
Methods
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.
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.
Known issues and limitations
The following actions and APIs aren’t supported on Vega:- Passing a remote asset to ‘source’ with a URI
.lottieformat assetsColorFiltersTextFilterVega

