@cloudpdf/viewer-react

中文文档
3.1.0发布于 2026/11/09Apache-2.0TypeScriptESM + CJS近 30 天下载 1756

The full viewer as a React component with the CloudPDF engine as its default: the same as @embedpdf/viewer-react, rendering on CloudPDF SaaS or your own @cloudpdf/server over HTTPS, the local engine loaded only when stamps need it.

原始使用文档
文档目录3 节
  1. It is the open viewer, with its engine swapped
  2. Documentation
  3. License

@cloudpdf/viewer-react

The full EmbedPDF viewer as a React component, with the CloudPDF engine as its default. There is no WebAssembly and no Web Worker in your bundle for reading: rendering happens on CloudPDF (the SaaS, or your own @cloudpdf/server), so the only thing that crosses the network is HTTPS API traffic.

npm install @cloudpdf/viewer-react
import { PDFViewer } from '@cloudpdf/viewer-react';

export function Report({ token }: { token: string }) {
  return <PDFViewer src={{ token }} style={{ height: '100vh' }} />;
}

src is the document: { token } with a document token your backend creates for the user (a string, or a function that gives a fresh one), { id } when the engine's own token already allows it, or { grant } with a grant from the dashboard. Another src opens in its place. For several documents at once, pass documents: entries of { src, name, password, active }.

The viewer connects to CloudPDF SaaS (https://engine.cloudpdf.com). Your own @cloudpdf/server goes in the engine's settings: engine: { baseUrl: 'https://pdf.example.com' }, with the engine's own token and fetch beside it.

It is the open viewer, with its engine swapped

This package is a door over @embedpdf/viewer-react, as that package is the same viewer with the built-in engine: the component is the same <PDFViewer>, and so is every name around it. Everything the open viewer accepts works here unchanged (layout, commands, icons, strings, theme, plugins, your components inside it, the ready callback) and its documentation applies verbatim. Only the documents are in the cloud's words.

<PDFViewer src={{ token }} onReady={(viewer) => …}>
  <ToolbarItem id="doc-status">
    <MyStatusChip />
  </ToolbarItem>
</PDFViewer>

Documentation

https://www.cloudpdf.com

License

Apache-2.0 — see LICENSE.

Everything CloudPDF ships to a browser is open source; everything that runs on a server is commercial. This package is browser-side, so it is Apache-2.0 — as is the viewer it wraps, from the EmbedPDF open-source project. Rendering happens on a CloudPDF deployment (the SaaS, or a self-hosted @cloudpdf/server under a separate written agreement), which is the commercial part.

版本与发布记录

@cloudpdf/viewer-react 共发布 26 个版本,首次发布于 2026/08/06;过去 12 个月发布了 26 个版本。

版本发布日期距今
3.1.0latest2026/11/091 天前
3.0.02026/11/073 天前
3.0.0-next.23next2026/11/073 天前
3.0.0-next.222026/11/045 天前
3.0.0-next.212026/11/036 天前
3.0.0-next.202026/11/037 天前

关于 @cloudpdf/viewer-react 的常见问题

@cloudpdf/viewer-react 是什么?

The full viewer as a React component with the CloudPDF engine as its default: the same as @embedpdf/viewer-react, rendering on CloudPDF SaaS or your own @cloudpdf/server over HTTPS, the local engine loaded only when stamps need it.

如何安装 @cloudpdf/viewer-react?

在项目目录运行 npm install @cloudpdf/viewer-react,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cloudpdf/viewer-react 支持 TypeScript 吗?

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

@cloudpdf/viewer-react 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@cloudpdf/viewer-react 可以商用吗?

@cloudpdf/viewer-react 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@cloudpdf/viewer-react 的下载量有多少?

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

@cloudpdf/viewer-react 还在维护吗?

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