@dotlottie/dotlottie-js

中文文档
1.10.0发布于 2026/11/11MITTypeScriptES Module构建来源已验证近 30 天下载 26.1万

This library helps in creating and modifying .lottie files.

原始使用文档
文档目录4 节
  1. Quick use guide
  2. Managing the manifest.json
  3. Usage in frameworks
  4. Development

dotlottie-js

dotLottie-js serves as the primary library for creating and abstracting dotLotties.

Full documentation available here.

Quick use guide

1. Install using your favourite package mananger

Install dotlottie-js

pnpm add @dotlottie/dotlottie-js
npm i @dotlottie/dotlottie-js
yarn install @dotlottie/dotlottie-js

Importing:

Browser

import { DotLottie } from '@dotlottie/dotlottie-js'

Node

import { DotLottie } from '@dotlottie/dotlottie-js/node'

2. Creating a dotLottie using the library

For more use cases check out the documentation on gitbook

import { DotLottie } from '@dotlottie/dotlottie-js';
//If running on Node
// import { DotLottie } from '@dotlottie/dotlottie-js/node';
import like_animation from './like.json';

async function createDotLottie(){
  const dotLottie = new DotLottie();

  // build dotLottie
  await dotLottie 
        .setAuthor('LottieFiles')
        .setVersion('1.0')
        .addAnimation({
          id: 'like_animation',
          data: like_animation,
          loop: true,
          autoplay: true
        })
        .addAnimation({
          id: 'cat_animation',
          url: 'https://my_cat_animation.json',
          loop: true,
          autoplay: false
        })
        .build()
  
  // download dotLottie
  await dotlottie.download('my_animation.lottie');
}

createDotLottie();

Managing the manifest.json

A manifest.json file will be present inside of your .lottie.

The manifest file allows the player to know what animations are contained inside it, how to play them and more. All of these settings are customizable by interacting with the DotLottie object and the LottieAnimations contained inside it.

There are two levels of customization possible, the first being on the dotLottie level which concerns things like the author, version of the animation and more. The second is on the animation level, setting options like autoplay, loop and more.

All of the dotLottie object customization options are visible here.

All of the animation object customization options are visible here.

Usage in frameworks

For examples on how to use in React, Next.js, Vue and Nuxt 3 please refer to the full documentation page.

Development


Guidelines

  • Use defensive programming techniques: Ensure type and range of input values, cast values to native representation whenever possible, etc.
  • Refrain from using external dependencies: Discuss before adding a dependency. Check with Bundlephobia for package size and dependencies when choosing one.
  • Use code formatting in the IDE using the given eslint+prettier configs.
  • Write tests to cover all functions and code branches with valid and invalid values.

Setting up

git clone https://github.com/dotlottie/dotottie-js

cd dotlottie-js

pnpm i

Building

pnpm run build

Running test suite

pnpm run test

版本与发布记录

@dotlottie/dotlottie-js 共发布 82 个版本,首次发布于 2023/05/05;过去 12 个月发布了 11 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.10.0latest2026/11/112 天前
1.9.02026/10/2915 天前
1.8.12026/10/091 个月前
1.8.02026/08/103 个月前
1.7.02026/07/034 个月前
1.6.32026/02/178 个月前

其他发布通道:beta → 0.9.0-beta.13,pre → 1.7.0-pre.3。

关于 @dotlottie/dotlottie-js 的常见问题

@dotlottie/dotlottie-js 是什么?

This library helps in creating and modifying .lottie files.

如何安装 @dotlottie/dotlottie-js?

在项目目录运行 npm install @dotlottie/dotlottie-js,或使用 pnpm add / yarn add / bun add。

@dotlottie/dotlottie-js 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dotlottie/dotlottie-js 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dotlottie/dotlottie-js 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.9.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@dotlottie/dotlottie-js 可以商用吗?

@dotlottie/dotlottie-js 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dotlottie/dotlottie-js 的下载量有多少?

根据 npm 官方下载统计,@dotlottie/dotlottie-js 在 2026/10/13 – 2026/11/11 这 30 天内被下载 261,177 次,日均约 8,706 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dotlottie/dotlottie-js 还在维护吗?

最新版本 1.10.0 发布于 2026/11/11(2 天前);至今共发布 82 个版本,其中过去 12 个月发布了 11 个;首次发布于 2023/05/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。