Skip to main content
Lottie to codeUpdated November 20265 min read

Lottie to React: how to play a Lottie file in React

The short answer

To play a Lottie file in React you render the exported JSON with a Lottie player, usually the community lottie-react wrapper around lottie-web. That gives you playback. If the animation needs states, drag physics or logic, import the JSON into ExodeUI instead and render the resulting .exode file with the exodeui package.

What matters

  • A Lottie file is a timeline. It plays back; it does not hold state, logic or physics.
  • The lottie-web players are the standard way to render one, and they render what you drew — nothing more.
  • You can import the same Lottie JSON into ExodeUI, add inputs, states and physics, and play the result with the ExodeUI runtime.
  • The converted file is .exode JSON, so it can live in the repo next to the component that uses it.
  • Neither route needs a subscription to ship. ExodeUI Community is free; Professional is $5 per month billed yearly.

Playing a Lottie file in React today

The standard approach is a player component that takes the exported JSON and renders it. It is small, it works, and if the animation is a decorative loader or a success tick, it is the right answer.

What it cannot do is change behaviour. If the design calls for the animation to react — pause on hover, spring back when dragged, switch to an error state when a request fails — that logic has to be written in your component around the player, and the animation itself stays fixed.

The import route

The other option is to move the animation into ExodeUI, where the timeline, the inputs and the logic live in one file. Drop your Lottie JSON on /import/lottie, check how it converts, then add states and physics to it on the canvas instead of in code.

React renders the compiled .bexode file, so the animation ships as a static asset next to the component that uses it.

We make ExodeUI, so treat that suggestion as the vendor recommending its own runtime. If the animation is a fixed performance with nothing to interact with, a Lottie player is the simpler answer.

The React code

Pass the file path as src and the values your component owns as inputs. Events come back through onTrigger, so React state stays the source of truth.

$npm install exodeui
React
import { ExodeUICanvas } from 'exodeui';

// loader.bexode lives in /public
export function Loader() {
  return (
    <ExodeUICanvas
      src="/loader.bexode"
      fit="Layout"
      autoPlay
      interactive
      inputs={{ progress: 0.4 }}
      onTrigger={(name) => {
        // named events fired from the file
      }}
      style={{ width: '100%', height: 160 }}
    />
  );
}

Inputs go in, events come out. The component you ship is a canvas that renders the file, not a pile of keyframes translated into framework code, so a designer can retune the spring without touching the component.

Which route to pick

Use the plain player when the animation is a one-way performance: a loading state, an empty-state illustration, a marketing flourish. There is nothing to interact with, so a timeline is the whole job.

Use the runtime when the thing on screen is a component people operate. A toggle, a drag-to-dismiss card, a form field with focus, loading, error and success states — those are not animations that play, they are motion bound to state, and putting the motion in the file keeps the component short.

Questions

How do I use a Lottie JSON file in React?

Import the JSON and render it with a Lottie player such as lottie-react, which wraps lottie-web. The animation plays inside a normal React component. If you need the animation to respond to state, the player API lets you control playback, but the logic lives in your component.

Do I need a LottieFiles subscription to play a Lottie file?

No. Lottie is an open JSON format and the players that render it are open source. A LottieFiles subscription buys the asset library, hosting and team workflow, not permission to render the format.

Can a Lottie file hold state or logic?

A Lottie file is a timeline. Interactivity comes from the player API — you call play, pause or go to a frame from your code — so the states live in your component, not in the file.

Does the Lottie import upload my file?

No. The conversion runs in your browser and the file stays on your device. Only a usage count is recorded.

Can I turn a Lottie file into an editable React component?

Not into JSX keyframes. You can convert it to an open .exode file in the browser, edit the layers, motion and states on a canvas, and render that file with the exodeui package. The React component stays small because the motion is not written in it.

Related

Open the editor and try it on your own file

Free Community plan. No credit card. One open .exode file runs in React, Vue, Flutter and more.

Open the web editor
ExodeUI

EXODEUI DESKTOP

A little space for good ideas.

Choose your platform to get the official ExodeUI installer.

Looking for Intel Mac or other builds? Explore the web studio or check all download options.

Prefer the browser? Try for free in your browser →