API Reference
API reference for the dotLottie React player covering the worker component, WASM configuration, instance access, and links to the full core API.
In addition to the DotLottieReact component (see the props reference), the @lottiefiles/dotlottie-react package provides the DotLottieWorkerReact component and the setWasmUrl function. DotLottieReact wraps the core dotLottie web player; the underlying DotLottie instance exposes the full core API.
DotLottieWorkerReact
DotLottieWorkerReact offloads animation rendering to a Web Worker, keeping the main thread free for UI interactions. It accepts the same props as DotLottieReact plus workerId.
import { DotLottieWorkerReact } from "@lottiefiles/dotlottie-react";
function App() {
return <DotLottieWorkerReact src="animation.lottie" autoplay loop workerId="shared-worker" />;
}| Prop | Type | Default | Description |
workerId | string | undefined | Groups multiple animations on the same Web Worker thread. Animations sharing a workerId reuse one worker, reducing overhead. |
All instance methods accessed via dotLottieRefCallback return Promise values when using DotLottieWorkerReact, since calls are proxied to the worker thread.
setWasmUrl
setWasmUrl(url: string) sets a custom URL for the WASM renderer binary. It must be called before any animation is rendered — for example, at the top of the app entry point.
import { setWasmUrl } from "@lottiefiles/dotlottie-react";
setWasmUrl("https://your-cdn.com/dotlottie-player.wasm");Player instance access
The dotLottieRefCallback prop (type React.RefCallback<DotLottie | null>) receives the underlying DotLottie web player instance:
import React from "react";
import { DotLottieReact } from "@lottiefiles/dotlottie-react";
function App() {
const [dotLottie, setDotLottie] = React.useState(null);
React.useEffect(() => {
if (!dotLottie) return;
const onLoad = () => {
console.log("Total frames:", dotLottie.totalFrames);
console.log("Duration:", dotLottie.duration);
};
dotLottie.addEventListener("load", onLoad);
return () => dotLottie.removeEventListener("load", onLoad);
}, [dotLottie]);
return <DotLottieReact src="animation.lottie" autoplay loop dotLottieRefCallback={setDotLottie} />;
}The instance exposes all properties, methods, and events of the core player:
Properties —
currentFrame,duration,totalFrames,isPlaying,isPaused,isStopped,isLoaded,loop,speed,mode,segment,manifest,activeAnimationId,activeThemeId, and more. See Properties.Methods —
play(),pause(),stop(),setFrame(),setSpeed(),setLoop(),setMode(),setSegment(),setMarker(),freeze(),unfreeze(),tween(),load(),loadAnimation(),setTheme(),setLayout(), slot methods, state machine methods, and more. See Methods.Events —
ready,load,loadError,play,pause,stop,loop,complete,frame,render,freeze,unfreeze,destroy,renderError, plus all state machine events. See Events.Types —
Layout,RenderConfig,StateMachineConfig,Transform,Marker, slot value types, and event payload interfaces. See Type Definitions.
Related topics
Props reference — Component props
Examples — Usage examples
JS API reference — Full core player API