Vue Lottie Player is a type-safe Vue 3 component and plugin for integrating Lottie animations into web applications, built as a wrapper around the `lottie-web` library. The current stable version is 2.0.2. This library prioritizes security and performance by offering a default 'light-player' build that is CSP-friendly and avoids `unsafe-eval`, alongside an opt-in '/full' entry for animations requiring After Effects expressions. It provides a robust API for both URL- and JSON-based animation sources, imperative ref controls for direct playback manipulation, and straightforward integration with Nuxt 3. Its key differentiators include built-in TypeScript types, a focus on CSP compliance, and a clear separation between a lean default build and a feature-rich full build.
npm install vue-lottie-playerVerified import paths — ran on the pinned version, not inferred.
Demonstrates importing the component, stylesheet, and types, then rendering a Lottie animation from a URL with basic controls.
Ensure your project uses Vue version ^3.4.0 or greater. Update Vue if necessary.
For animations requiring After Effects expressions, import from the `/full` entry point: `import { VueLottiePlayer } from 'vue-lottie-player/full';`. Be aware that this build may violate strict CSP policies.Create a client-side Nuxt plugin (e.g., `plugins/vue-lottie-player.client.ts`) and wrap component usage in `pages/*.vue` with `<ClientOnly>...</ClientOnly>`.
Add `import 'vue-lottie-player/style.css';` to your main application entry file or a global stylesheet.
Ensure the Lottie player ref is initialized (`ref<VueLottiePlayerInstance | null>(null)`) and that methods are called only after the component is mounted or the `@ready` event has fired. Check that `player.value` is not null before calling methods.
If using as a component, ensure `import { VueLottiePlayer } from 'vue-lottie-player';` is present in your script. If intended for global use, ensure `createApp(App).use(VueLottiePlayerPlugin).mount('#app');` is configured.If your animation requires expressions, switch to the full build: `import { VueLottiePlayer } from 'vue-lottie-player/full';`. Otherwise, simplify your Lottie animation to avoid expressions.