Registry / web-framework / vite-plugin-lottie

vite-plugin-lottie

JSON →
library1.0.1jsnpmunverified

Vite plugin that enables import of Lottie JSON animation files as parsed animation data. Current version 1.0.1 (released 2023). Bundles Lottie files into the application by transforming imports with the `?lottie` query suffix. Designed exclusively for Vite, requires Lottie-web as runtime dependency. Provides TypeScript type declarations for the query suffix. Differentiates from other Lottie loaders by being a minimal, zero-config Vite plugin without additional bundler configuration.

npm install vite-plugin-lottie
INSTALL
IMPORT
SIG · VITE-PLUGIN-LOTTIE
V
vite-plugin-lottie
web-frameworkjavascriptv1.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

lottie
import { lottie } from 'vite-plugin-lottie'
import lottie from 'vite-plugin-lottie'
Named export, not default.
animationData
import animationData from './animation.json?lottie'
import animationData from './animation.json'
Must append ?lottie query to trigger the plugin.
vite-plugin-lottie/client
/// <reference types="vite-plugin-lottie/client" />
import 'vite-plugin-lottie/client'
Triple-slash directive for TypeScript type augmentation; not a runtime import.

Setup Vite plugin in config and use ?lottie import in Vue component to load animation.

// vite.config.ts import { defineConfig } from 'vite' import { lottie } from 'vite-plugin-lottie' export default defineConfig({ plugins: [lottie()], }) // App.vue <script setup lang="ts"> import Lottie from 'lottie-web' import animationData from './animation.json?lottie' import { onMounted } from 'vue' onMounted(() => { Lottie.loadAnimation({ container: document.getElementById('lottie-container'), renderer: 'svg', loop: true, autoplay: true, animationData: animationData }) }) </script> <template> <div id="lottie-container" style="width: 200px; height: 200px;"></div> </template>
Debug
Known issues
gotchaYou must append ?lottie to the import path, otherwise Vite will try to parse JSON as JavaScript and fail.
fix
Use import animationData from './animation.json?lottie'
affects: >0.0.0
gotchaThe plugin only transforms imports with ?lottie query; regular JSON imports are unaffected.
fix
Ensure all Lottie file imports end with ?lottie
affects: >0.0.0
deprecatedPlugin does not bundle lottie-web itself; you must install lottie-web separately.
fix
Install lottie-web as a regular dependency: npm install lottie-web
affects: >0.0.0
gotchaTypeScript users must add triple-slash reference to enable type checking for ?lottie imports.
fix
Add /// <reference types="vite-plugin-lottie/client" /> in a .d.ts file or tsconfig include.
affects: >0.0.0
Errors
Common errors & fixes
Cannot find module './animation.json?lottie' or its corresponding type declarations.
TypeScript does not know about the ?lottie query suffix without type augmentation.
fix
Add /// <reference types="vite-plugin-lottie/client" /> in a .d.ts file or in your tsconfig's include.
Failed to load import './animation.json' from 'src/App.vue'. Unexpected token '}' in JSON at position...
Importing a .json file without the ?lottie query, causing Vite to treat it as plain JSON.
fix
Change import to './animation.json?lottie'.
Lottie is not defined
Missing lottie-web runtime dependency; the plugin does not include Lottie player.
fix
Install lottie-web: npm install lottie-web
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
viterequiredpeer dependency required for plugin to function
lottie-weboptionalruntime dependency for Lottie player; must be installed separately
Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
2
Resources
vite-plugin-lottie — npm install vite-plugin-lottie · libregistry