@cometchat/cards-react

中文文档
1.0.0发布于 2026/05/27https://www.cometchat.com/legal-terms-of-serviceTypeScriptESM + CJS近 30 天下载 9234

CometChat Card Schema renderer — React wrapper

原始使用文档
文档目录7 节
  1. What it does
  2. Installation
  3. Peer Dependencies
  4. Usage
  5. Getting Started
  6. Prerequisites
  7. Help and Support

CometChat Card Renderer React

A React component for rendering CometChat Card Schema JSON. This is a thin wrapper around @cometchat/cards that mounts the vanilla DOM output into a React component with full lifecycle management.

What it does

  • Renders Card Schema JSON as a native React component
  • Reactively re-renders on prop changes (cardJson, themeMode, themeOverride, logLevel)
  • Automatically cleans up DOM and theme observers on unmount
  • Emits clicks on buttons, icon buttons, and links to your callback as typed CometChatCardActionEvents

The package is a pure renderer. It doesn't talk to the CometChat SDK, doesn't manage message lifecycle, and doesn't know about your app's routing. You decide what each action does.

Installation

npm install @cometchat/cards-react

@cometchat/cards-react includes @cometchat/cards as a dependency — no need to install both.

Peer Dependencies

  • react >= 17.0.0
  • react-dom >= 17.0.0

Usage

import { CometChatCardView } from "@cometchat/cards-react";

function CardMessage({ cardJson }: { cardJson: string }) {
  return (
    <CometChatCardView
      cardJson={cardJson}
      themeMode="auto"
      onAction={(event) => {
        console.log("action:", event.action.type, "from", event.elementId);
      }}
    />
  );
}

Getting Started

Refer to the Integration Steps to integrate the react cards into your app.

Prerequisites

  • Node.js >= 14.17.0
  • npm >= 7
  • React >= 17.0.0

Help and Support

For integration issues, create a support ticket or seek real-time support via the CometChat Dashboard.

版本与发布记录

@cometchat/cards-react 共发布 1 个版本,首次发布于 2026/05/27;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.0.0latest2026/05/275 个月前

关于 @cometchat/cards-react 的常见问题

@cometchat/cards-react 是什么?

CometChat Card Schema renderer — React wrapper

如何安装 @cometchat/cards-react?

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

@cometchat/cards-react 支持 TypeScript 吗?

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

@cometchat/cards-react 支持 ESM 还是 CommonJS?

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

@cometchat/cards-react 可以商用吗?

@cometchat/cards-react 使用 https://www.cometchat.com/legal-terms-of-service 许可。声明的许可为 https://www.cometchat.com/legal-terms-of-service,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@cometchat/cards-react 的下载量有多少?

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

@cometchat/cards-react 还在维护吗?

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