@creatomate/preview

中文文档
1.6.1发布于 2026/09/03MITTypeScriptCommonJS零依赖近 30 天下载 9.3万

Render video and image previews in your web app prior to creating a final MP4, GIF, JPEG or PNG through the API.

原始使用文档
文档目录6 节
  1. Usage
  2. Installation
  3. Demo
  4. Compatibility
  5. Issues & Comments
  6. License

Creatomate Preview SDK

The Preview SDK lets you display video and image previews in your web app prior to creating a final MP4, GIF, JPEG or PNG through the API. This is useful when developing a web-based editing or customizer tool, and want to show a real-time rendering in the browser.

This package is for browser-based apps, and it works with any framework such as React, Angular, Vue, as well as plain Javascript. For creating videos and images using Node.js, refer to the creatomate library instead, a different NPM package that can be found here.

Creatomate is a media generation API for editing and rendering videos and images using code. The platform uses templates and JSON for generating MP4, GIF, JPEG or PNG files. All processing is handled by Creatomate's cloud infrastructure, so you do not need to maintain your own servers.

Usage

Installation

Install the package using the following command:

npm install @creatomate/preview

You can now load a video template (or JSON) as follows:

import { Preview } from '@creatomate/preview';

// The following assumes that you have a HTML element like this: <div id="container"></div>
const containerElement = document.getElementById('container');

// Initialize a preview to be spawned within the container
const preview = new Preview(containerElement, 'player', 'YOUR_VIDEO_PLAYER_TOKEN');

// Once the SDK is ready, load a template from the project
preview.onReady = async () => {
  await preview.loadTemplate('YOUR_TEMPLATE_ID');
  
  // You can also load a video from JSON:
  // await preview.setSource({ /* Your JSON here */ });
};

Check out the demo code provided below for a more comprehensive example.

Demo

See the Preview SDK in action here: Video Preview Demo

Compatibility

Because live video rendering is very demanding on the device's hardware, this library only works on modern desktop web browsers, such as Chrome, Firefox, Edge, Opera, and Safari. Mobile devices are not supported. Render an MP4 preview through the API to support smartphone devices. Tip: Use the render_scale API parameter (10% to 100%) to generate a low-resolution preview without changing the composition or template.

Issues & Comments

Feel free to contact us if you encounter any issues with the library or Creatomate API at [email protected].

License

The Creatomate Preview SDK is licensed under the MIT license. Please refer to the LICENSE for more information.

版本与发布记录

@creatomate/preview 共发布 11 个版本,首次发布于 2023/05/19;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.6.1latest2026/09/032 个月前
1.6.02025/04/021.6 年前
1.5.02024/05/172 年前
1.4.12024/03/252 年前
1.4.02024/01/022 年前
1.3.02023/11/112 年前

关于 @creatomate/preview 的常见问题

@creatomate/preview 是什么?

Render video and image previews in your web app prior to creating a final MP4, GIF, JPEG or PNG through the API.

如何安装 @creatomate/preview?

在项目目录运行 npm install @creatomate/preview,或使用 pnpm add / yarn add / bun add。

@creatomate/preview 支持 TypeScript 吗?

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

@creatomate/preview 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@creatomate/preview 可以商用吗?

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

@creatomate/preview 的下载量有多少?

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

@creatomate/preview 还在维护吗?

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