@chatra/chatra

中文文档
1.0.3发布于 2021/05/22ISCCommonJS零依赖近 30 天下载 2287

Official Chatra module

原始使用文档
文档目录6 节
  1. Installation
  2. Configuration
  3. Advanced Usage
  4. Updating the settings
  5. Methods
  6. Contact us

Chatra logo

:triangular_flag_on_post: This package is intended for developers. If you just want to add Chatra to your website, check our Installation guides for popular e-commerce platforms and content management systems or just add a small code snippet to your website.

Official Chatra module

This module loads the Chatra widget and passes method calls to the Javascript API.

Key Features:

  • Easy integration with your website or web app
  • Works perfectly with React, Angular, Vue, and other frameworks
  • Uses ES5 for maximum compatibility, doesn’t require transpiling.

Installation

To add the chat widget to your website or web app, sign up with Chatra.

If you already have an account, install the package using your favorite package manager:

$ npm install @chatra/chatra
$ yarn add @chatra/chatra

Configuration

Step 1. Go to the Preferences section of your Chatra dashboard and copy the Public key.

Step 2. Initialize the widget in your index.js or root controller

index.js

let Chatra = require('chatra')

let config = {
    ID: 'Paste your Public key here'
}

Chatra('init', config)

:triangular_flag_on_post: You can customize the chat and button appearance, localization, and lots of other settings by passing setup to the initialization config. Please check the Javascript API documentation for details.

index.js

let config = {
    setup: {
        buttonSize: 75
    },
    ID: 'Paste your ChatraID here'
}

Moreover, you can pass arbitrary visitor info using the integration key:

index.js

let config = {
    integration: {
        name: 'Cowardly Lion',
        email: '[email protected]',

        /* any number of custom properties */
        'What does he do': 'Goes to Oz with his friends'
    },
    ID: 'Paste your ChatraID here'
}

Step 3 (optional). Call PageView to enable Targeted chats & triggers.

If your website or web app loads pages dynamically and updates the document’s URL without requiring a full page load, call the following method whenever the page changes to track these views and see them in the Chatra dashboard:

Chatra('pageView')

We recommend calling this method in your router or page controllers.

Advanced Usage

Updating the settings

You can update the settings after initialization by calling Chatra('init', config) again, which will restart Chatra with the new settings applied.

Methods

Methods are used to dynamically change the behavior of the chat widget. Methods can be called anywhere after the widget initialization, for example:

Chatra('expandWidget')

All method calls made before Chatra finished loading are put into a queue and executed when Chatra is ready.

Contact us

If you have any questions, feel free to contact us.

版本与发布记录

@chatra/chatra 共发布 4 个版本,首次发布于 2021/05/20;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.3latest2021/05/225 年前
1.0.22021/05/215 年前
1.0.12021/05/215 年前
1.0.02021/05/205 年前

关于 @chatra/chatra 的常见问题

@chatra/chatra 是什么?

Official Chatra module

如何安装 @chatra/chatra?

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

@chatra/chatra 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/chatra__chatra 是否存在。

@chatra/chatra 支持 ESM 还是 CommonJS?

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

@chatra/chatra 可以商用吗?

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

@chatra/chatra 的下载量有多少?

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

@chatra/chatra 还在维护吗?

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