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" />;
}
PropTypeDefaultDescription
workerIdstringundefinedGroups 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:

  • PropertiescurrentFrame, duration, totalFrames, isPlaying, isPaused, isStopped, isLoaded, loop, speed, mode, segment, manifest, activeAnimationId, activeThemeId, and more. See Properties.

  • Methodsplay(), pause(), stop(), setFrame(), setSpeed(), setLoop(), setMode(), setSegment(), setMarker(), freeze(), unfreeze(), tween(), load(), loadAnimation(), setTheme(), setLayout(), slot methods, state machine methods, and more. See Methods.

  • Eventsready, load, loadError, play, pause, stop, loop, complete, frame, render, freeze, unfreeze, destroy, renderError, plus all state machine events. See Events.

  • TypesLayout, RenderConfig, StateMachineConfig, Transform, Marker, slot value types, and event payload interfaces. See Type Definitions.

Last updated: August 13, 2026 at 9:17 AMEdit this page