@chatkitty/core

中文文档
2.106.2发布于 2025/10/11MITTypeScriptESM + CJS零依赖近 30 天下载 6872

A powerful tool for integrating chat features into your web applications.

原始使用文档
文档目录5 节
  1. Installation
  2. Basic Usage
  3. Loading the Chat UI
  4. Connecting to ChatKitty manually
  5. Customizing the Chat Experience

@chatkitty/core

Installation

npm install @chatkitty/core

Basic Usage

Check out the HTML example for a complete working example.

npx chatkitty html-example:serve

Loading the Chat UI

import { loadChatUi } from '@chatkitty/core';

await loadChatUi({
  widgetId: 'YOUR_WIDGET_ID',
  username: 'USER_USERNAME',
  container: {
    id: 'chat-ui',
    height: '100%',
  },
});

// Define the container in your HTML
// <div id="chat-ui"></div>

Connecting to ChatKitty manually

To connect to the ChatKitty API manually, use your API key and the username of the user who is connecting. This is useful if you want to extend functionality programmatically or need access to the SDK client.

import { connectApi } from '@chatkitty/core';

const apiKey = 'YOUR_CHATKITTY_API_KEY';
const username = 'USER_USERNAME';

const connection = await connectApi({
  apiKey: apiKey,
  username: username,
});

const { user, notifications, updateUser } = connection;

console.log('Connected as user:', user.value);

// Set event listeners if needed
user.watch((user) => console.log('User updated:', user));

// optional: get SDK client
const client = connection.getSdkClient();

// Load Chat UI using existing connection
await loadChatUi({
    widgetId: 'YOUR_WIDGET_ID',
    container: {
        id: 'chat-ui',
        height: '100%',
    }, { connection }
);

// Don't forget to disconnect when done
await connection.dispose();

Customizing the Chat Experience

ChatKitty allows for extensive customization of the chat UI and behavior through themes, localization, audio notifications, and much more. For example, to customize the theme and provide a custom user profile:

await loadChatUi({
  widgetId: 'YOUR_WIDGET_ID',
  theme: 'dark',
  profile: {
    displayName: 'John Doe',
    displayPicture: 'https://example.com/user-avatar.jpg',
  },
  // Other options...
});

Check out the ChatKitty UI documentation for a full list of customization options.

版本与发布记录

@chatkitty/core 共发布 54 个版本,首次发布于 2022/07/28;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.106.2latest2025/10/111.1 年前
2.105.82025/09/291.1 年前
2.105.22025/09/231.1 年前
2.105.12025/09/231.1 年前
2.105.02025/09/221.1 年前
2.97.22025/08/241.2 年前

关于 @chatkitty/core 的常见问题

@chatkitty/core 是什么?

A powerful tool for integrating chat features into your web applications.

如何安装 @chatkitty/core?

在项目目录运行 npm install @chatkitty/core,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@stomp/rx-stomp(^2.2.0)、axios(^1.12.2)、lit-html(^3.3.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@chatkitty/core 支持 TypeScript 吗?

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

@chatkitty/core 支持 ESM 还是 CommonJS?

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

@chatkitty/core 需要什么版本的 Node.js?

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

@chatkitty/core 可以商用吗?

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

@chatkitty/core 的下载量有多少?

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

@chatkitty/core 还在维护吗?

最新版本 2.106.2 发布于 2025/10/11(1.1 年前);至今共发布 54 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/07/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。