@archbee/app-widget

中文文档
1.1.43发布于 2026/10/20UNLICENSEDES Module近 30 天下载 1781
原始使用文档
文档目录8 节
  1. Table of Contents
  2. Installation
  3. API documentation
  4. Examples
  5. Component Props
  6. Bubble
  7. Ref Methods
  8. Demos

Archbee React Component Widget

Table of Contents

Installation

To install, use pnpm:

$ pnpm add @archbee/app-widget

If you need to install Archbee Contextual Widget SDK, you can find more details here.

API documentation

The primary documentation for Archbee React component Widget can be found in docs, which describes the API and gives examples of its usage.

Examples

Here is a simple example of Archbee React widget being used in an app with some action variations:

import React from 'react'
import { ArchbeeAppWidget } from '@archbee/app-widget'

function App() {
  return (
    <div>
      <ArchbeeAppWidget
        spaceId={/** published space id **/}
        onWidgetOpen={() => {
          /** ... **/
        }} // callback function called after widget has open
        // onWidgetClose={() => { /** ... **/ }} // callback function called after widget has open
      >
        <button type="button">Open</button>
      </ArchbeeAppWidget>
    </div>
  )
}

ReactDOM.render(<App />, appElement)

Can also be used with ref for a more programmatic approach:

import React from 'react';
import { ArchbeeAppWidget, AbWidgetRef } from '@archbee/app-widget'

function App() {
const widgetRef = useRef<AbWidgetRef>(null);

  return (
    <div>
        <ArchbeeAppWidget
            ref={widgetRef}
            spaceId={ /** published space id **/ }
            onWidgetOpen={() => { /** ... **/ }} // callback function called after widget has open
            onWidgetClose={() => { /** ... **/ }} // callback function called after widget has open
      >
        <button type='button' onClick={() => {
        <!-- Opens widget -->
            widgetRef.current?.open();
        }}>
          Open
        </button>

        <button type='button' onClick={() => {
        <!-- Closes widget -->
            widgetRef.current?.close();
        }}>
          Close
        </button>

        <button type='button' onClick={() => {
        <!-- Gets the instance of the widget if needed for various event manipulations. -->
            widgetRef.current?.instance();
        }}>
          Get widget instance
        </button>
      </ArchbeeAppWidget>
    </div>
  );
}

ReactDOM.render(<App />, appElement);

Component Props

PropertyTypeRequiredDescription
spaceIdstringrequiredPass the desired id to load your docs.
docIdstringoptionalThe doc where you want to open the widget docs. If docId is passed, widgetType is ignored, it will open in docs mode regardless of prop passed.
blockIdstringoptionalThe block where you want to scroll, after a certain document was open.
jwtstringoptionalPass the jwt token in order to see jwt protected docs.
shareableTokenstringoptionalPass the shareableToken from your private links to protect your docs.
classNamestringoptionalPass CSS classes to the div wrapper
widgetTypedocs | searchoptionalDefault value is docs. This opens the widget with the desired behaviour. docs`` type will open the widget with the default behaviour, search` will open a search widget bar that shows a search bar with AI support (if included in your subscription)
bubbleask | invisibleoptionalDefault value is invisible. This prop will display an ask bubble in the bottom-right of your screen. Whenever someone clicks on it, the search widget will open.
loadingStrategyeager | lazyoptionalDefault value is lazy. While lazy loading delays the initialization of a resource, eager loading initializes or loads the widget as soon as the code is executed.
anchorstringoptionalYou can provide your class, id or path to a DOM element where you would like the widget to anchor and instantiate. The container provided should have position: relative as the widget will be displayed based on the first relative parent found.
onWidgetOpenvoidoptionalCallback that is called after widget opens.
onWidgetClosevoidoptionalCallback that is called after widget closes.
hideNavbarbooleanoptionalDefault value is false. It hides the header navbar from the modal.
initialSearchQuerystringoptionalPre-populates the search input and triggers a search when the widget opens. Use with widgetType: "search" to open the widget with results already showing.

Bubble

Use bubble prop whenever you want an easy search button to browse your entire documentation.

Ask search bubble

Ref Methods

If ref is not passed to ArchbeeAppWidget, the children will automatically open the modal popup upon click.

PropertyTypeDescription
openmethodOpens widget programatically.
closemethodCloses widget programatically.
instancemethodReturns the instance of the widget.

Demos

Down below is a demo setup in CodeSandbox, which demonstrate various features of archbee-app:

版本与发布记录

@archbee/app-widget 共发布 104 个版本,首次发布于 2023/11/17;过去 12 个月发布了 10 个版本。

版本发布日期距今
1.1.43latest2026/10/2019 天前
1.1.422026/05/295 个月前
1.1.412026/05/225 个月前
1.1.402026/05/225 个月前
1.1.392026/05/086 个月前
1.1.382026/05/086 个月前

关于 @archbee/app-widget 的常见问题

@archbee/app-widget 是什么?

Installation - API documentation - Examples

如何安装 @archbee/app-widget?

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

@archbee/app-widget 支持 TypeScript 吗?

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

@archbee/app-widget 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@archbee/app-widget 可以商用吗?

@archbee/app-widget 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@archbee/app-widget 的下载量有多少?

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

@archbee/app-widget 还在维护吗?

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