DEV Community

Cover image for A Beginner’s Guide to React Native Animations with Lottie
Vikas Singh for Brilworks

Posted on

A Beginner’s Guide to React Native Animations with Lottie

Introduction

Animations make mobile apps feel clear and alive. They guide attention, reduce friction, and add delight without getting in the way. If you want that effect in React Native without heavy assets or complex code, Lottie is the easiest path.

Lottie plays vector animations from small JSON files. You drop the file into your project, render it like any other component, and control it with props. The result is smooth React Native animations that look sharp on every screen and stay light on performance.

In this beginner friendly guide we will set up lottie react native, render your first animation, add basic controls like play pause and loop, and cover a few performance tips. You will also see common use cases that make sense for a production app.

Quick prep before you start

  • Grab a tiny JSON from LottieFiles. Aim for under 300 KB.

  • Test early on a real device to check performance.

  • Keep animations purposeful. Use them to clarify an action or state change.

What is Lottie in React Native?

Lottie is an open source library created by Airbnb that lets you run animations exported as JSON files from Adobe After Effects. Instead of relying on heavy video files or building complex animations with code, you get lightweight vector animations that render natively on iOS and Android.

In React Native, you use lottie react native, a wrapper around the Lottie library. It gives you a component that makes it simple to load and control animations. You can auto play them when the component mounts, loop them indefinitely, or trigger them with user interactions.

Why developers love Lottie in React Native:

  • Cross platform – the same JSON file works on both iOS and Android.

  • Lightweight – animations are small and scalable without pixelation.

  • Easy integration – import the JSON and render it like any other component.

  • Smooth performance – animations run at 60 FPS without draining resources.

In short, Lottie is a way to bring polished motion design into React Native apps without needing to hand code every animation frame.

Setting Up Lottie in React Native

To get started with Lottie, you need to install the official lottie react native package along with the Lottie dependency for your platform. If you are using React Native CLI, here’s the process:

1. Install the packages

npm install lottie-react-native lottie-ios
Enter fullscreen mode Exit fullscreen mode

Or

yarn add lottie-react-native lottie-ios
Enter fullscreen mode Exit fullscreen mode

2. iOS setup

Navigate to the ios folder and install pods:

cd ios && pod install
Enter fullscreen mode Exit fullscreen mode

Make sure you open the .xcworkspace file when running the app on iOS.

3. Android setup

On Android, the package works out of the box after installation, so you don’t need extra steps.

4. Importing into your project

Once installed, you can import the LottieView component like this:

import LottieView from 'lottie-react-native';
Enter fullscreen mode Exit fullscreen mode

Now you’re ready to load your first animation. You just need a JSON animation file (commonly downloaded from LottieFiles.com). Place it inside your project’s assets folder or keep it in a dedicated animations folder.

Next section will be Using Lottie Animations in Your App where we’ll render a basic animation and explore props like autoPlay, loop, and event triggers.

Using Lottie Animations in Your App

Once the setup is done, rendering your first animation is straightforward. All you need is a JSON file and the component.

1. A basic example

import React from 'react';

import { View, StyleSheet } from 'react-native';

import LottieView from 'lottie-react-native';

export default function App() {

return (

<View style={styles.container}>

<LottieView

source={require('./assets/animation.json')}

autoPlay

loop

/>

</View>

);

}

const styles = StyleSheet.create({

container: {

flex: 1,

justifyContent: 'center',

alignItems: 'center',

},

});
Enter fullscreen mode Exit fullscreen mode

Here, the animation starts as soon as the component mounts (autoPlay) and keeps repeating (loop).

2. Controlling animations with actions

You can also control animations manually. For example, play an animation when a button is pressed:

import React, { useRef } from 'react';

import { View, Button } from 'react-native';

import LottieView from 'lottie-react-native';

export default function App() {

const animationRef = useRef(null);

return (

<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>

<LottieView

ref={animationRef}

source={require('./assets/animation.json')}

loop={false}

/>

<Button title="Play Animation" onPress={() => animationRef.current.play()} />

</View>

);

}
Enter fullscreen mode Exit fullscreen mode

This approach is great when you want to trigger animations for specific events, such as showing a checkmark after form submission.

3. Common props you’ll use often

  • autoPlay: start animation automatically

  • loop: repeat the animation indefinitely

  • speed: adjust playback speed

  • progress: set a specific frame or progress percentage

Best Practices for Lottie Animations

Lottie makes it easy to bring motion into React Native apps, but like any tool, it works best when used thoughtfully. These practices will help you keep animations smooth, lightweight, and meaningful for the user.

1. Keep animation files lightweight

Lottie animations are JSON files, and while they are smaller than videos or GIFs, they can still grow large if the design is complex. Aim for animations under 300 KB when possible. Heavier files not only increase app size but may also cause stutters on lower-end devices.

2. Simplify before exporting

If you are working with a designer, remind them that not every After Effects effect translates well to Lottie. Features like gradients, masks, or expressions can add unnecessary complexity. A simpler export runs faster and looks consistent across platforms.

3. Preload important animations

Animations used on splash screens, onboarding, or login flows should be preloaded. This ensures the animation starts instantly rather than showing a blank frame while the JSON loads. You can store critical animations locally in your assets folder for reliability.

4. Balance motion and usability

Animations should enhance the experience, not slow it down. For example, a checkmark animation after form submission should be short and snappy, not a 5-second flourish. Motion works best when it communicates state changes quickly.

5. Optimize for both platforms

Even though Lottie is cross-platform, rendering performance can differ on iOS and Android. Always test on physical devices to confirm animations feel smooth. What runs well on iOS might lag slightly on older Android devices.

6. Consider fallback options

If an animation fails to load, your app should still communicate the necessary feedback. For example, show a static image of a checkmark if the success animation cannot play.

7. Use caching wisely

For animations that repeat across the app, caching can reduce load times. This is especially useful in cases like loaders or progress indicators that appear often.

Final Thoughts

Animations can turn a functional app into an experience that feels polished and alive. With Lottie in React Native, you do not need to be an animation expert or ship heavy media files to achieve that effect. A simple JSON file and the component are enough to add smooth, scalable motion to your app.

We walked through what Lottie is, how to set it up, and the basics of playing and controlling animations. With a few best practices like keeping files light, preloading where it matters, and testing across platforms, you can make sure your animations feel smooth and purposeful.

For anyone exploring react native app development, Lottie is a powerful way to add animations without adding complexity. The best animations are the ones users barely notice because they make the interface feel natural.

Top comments (0)