Skip to main content
Lottie to codeUpdated November 20265 min read

Lottie to Vue: how to play a Lottie file in Vue 3

The short answer

In Vue you either mount a Lottie player component with the exported JSON, or you import the animation into ExodeUI and render the resulting .exode file with the exodeui-vue package. The player gives you playback controlled through Vue refs; the runtime gives you the states, inputs and physics in the file itself.

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 Vue 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.

Vue loads the .exode JSON file, so keep it with your other assets and import or fetch it by path.

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 Vue code

The Vue runtime takes the .exode JSON directly. Bind inputs with :inputs and listen for events with @trigger.

$npm install exodeui-vue
Vue 3
<script setup>
import { ExodeUICanvas } from 'exodeui-vue';

const inputs = { progress: 0.4 };

const onTrigger = (name) => {
  // named events fired from the file
};
</script>

<template>
  <ExodeUICanvas
    src="/loader.exode"
    fit="Layout"
    :inputs="inputs"
    @trigger="onTrigger"
    style="width: 100%; height: 160px"
  />
</template>

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 render a Lottie animation in Vue 3?

Use a Vue wrapper around lottie-web, or mount lottie-web directly in onMounted and destroy the instance in onUnmounted. Either way the JSON is the animation and your component controls playback through the player instance.

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.

Is there a Vue-specific Lottie runtime?

Yes. Lottie players exist for Vue as community wrappers, and ExodeUI publishes a Vue runtime of its own (exodeui-vue) that renders .exode files and takes inputs and events as normal Vue props and events.

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 →