For Windows (React Native >= 0.63), follow these steps to configure your project.
1. Project File Configuration
Add the following to the end of your project file (.vcxproj or .csproj). For C# apps, place this after any Microsoft.Windows.UI.Xaml.CSharp.targets includes. For C++ apps, place this after any Microsoft.Cpp.targets includes.
<PropertyGroup Label="LottieReactNativeProps">
<LottieReactNativeDir>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'node_modules\lottie-react-native\package.json'))\node_modules\lottie-react-native</LottieReactNativeDir>
</PropertyGroup>
<ImportGroup Label="LottieReactNativeTargets">
<Import Project="$(LottieReactNativeDir)\src\windows\cppwinrt\PropertySheets\LottieGen.Auto.targets" />
</ImportGroup>
Add the LottieReactNative.vcxproj file to your Visual Studio solution.
2. NuGet Package Installation
For C# apps:
LottieGen.MsBuildMicrosoft.UI.XamlWin2D.uwpMicrosoft.Toolkit.Uwp.UI.Lottie (Required for loading JSON dynamically. If using only codegen, set <EnableLottieDynamicSource>false</EnableLottieDynamicSource> and omit this).
For C++ apps:
LottieGen.MsBuildMicrosoft.UI.Xaml
Note: WinUI 2.6 (Microsoft.UI.Xaml 2.6.0) is required by default.
3. Register the Provider
C# Implementation:
PackageProviders.Add(new LottieReactNative.ReactPackageProvider(new AnimatedVisuals.LottieCodegenSourceProvider()));
C++ Implementation:
#include <winrt/LottieReactNative.h>
#include <winrt/AnimatedVisuals.h>
...
PackageProviders().Append(winrt::LottieReactNative::ReactPackageProvider(winrt::AnimatedVisuals::LottieCodegenSourceProvider()));
4. Using Codegen Animations
Add LottieAnimation items to your project file to compile them into the application:
<ItemGroup>
<LottieAnimation Include="Assets/Animations/MyAnimation.json" Name="MyAnimation" />
</ItemGroup>
Then use it in JavaScript:
<LottieView source={"MyAnimation"} style={{width: "100%", height: "100%"}} />