Vue3-lottie is a component library that enables developers to easily integrate Lottie animations into their Vue 3 and Nuxt 3 applications. It wraps `lottie-web` and provides a declarative API through a `<Vue3Lottie>` component, supporting a wide range of Lottie features like autoplay, looping, speed control, and segment playback. The current stable version is 3.3.1, with frequent patch and minor releases addressing bugs, improving types, and adding features. Key differentiators include its strong TypeScript support (enhanced in v3.0.0), seamless integration with the Vue ecosystem, and specific guidance for Nuxt 3. It abstracts away much of the complexity of directly using `lottie-web`, making it accessible for Vue developers. The library is actively maintained, ensuring compatibility with the latest Vue and Nuxt versions.
npm install vue3-lottieVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to integrate and control a Lottie animation using the `Vue3Lottie` component in a Vue 3 application. It shows basic setup with local animation data, controlling playback direction, and handling component mount events. Remember to replace `./assets/lottie-animation.json` with your actual Lottie JSON file.
Review the official v3 documentation for updated TypeScript usage. Remove explicit imports for `dist/style.css` as it's no longer necessary or provided in the same manner. Ensure you are using the correct component import style (default export).
Always use `import Vue3Lottie from 'vue3-lottie'` for importing the main component. Do not use `import { Vue3Lottie } from 'vue3-lottie'`.Create a Nuxt plugin (e.g., `plugins/lottie.client.ts`) and register the component using `nuxtApp.vueApp.component('Vue3Lottie', Vue3Lottie);` as demonstrated in the Nuxt 3 import example.Ensure that `animationData` is the actual parsed Lottie JSON. For files, `import AnimationData from 'path/to/animation.json'` handles this. If using a URL, pass the URL string to the `animationLink` prop introduced in v3.2.0.
Change the import statement from `import { Vue3Lottie } from 'vue3-lottie'` to `import Vue3Lottie from 'vue3-lottie'`.If in Nuxt 3, ensure you have a client-side plugin registering the component: `nuxtApp.vueApp.component('Vue3Lottie', Vue3Lottie);`. In a standard Vue CLI/Vite project, ensure it's imported and declared in the `components` option of your parent component or globally registered.Import `Vue3Lottie` in your script section (`import Vue3Lottie from 'vue3-lottie';`) and register it in the `components` option of your Vue component: `{ components: { Vue3Lottie } }`.