@gleanwork/web-sdk

中文文档
2.5.0发布于 2026/10/01MITTypeScriptCommonJS零依赖近 30 天下载 12万

Library for embedding Glean UI components

原始使用文档
文档目录5 节
  1. NPM
  2. Installation
  3. Usage
  4. Script tag
  5. Documentation

Glean Web SDK

The Glean Web SDK enables integration of AI powered search and chat functionalities into your existing intranet portal. The toolkit offers different variants to suit various use-cases and provide a streamlined search experience.

NPM

We recommend to use the @gleanwork/web-sdk when integrate with Glean, it will provide proper type support as well.

Installation

Install the Glean Web SDK with the following command:

// npm
npm install @gleanwork/web-sdk

// yarn
yarn add @gleanwork/web-sdk

// pnpm
pnpm add @gleanwork/web-sdk

Usage

// Can import all methods in one namespace GleanWebSDK
import GleanWebSDK, { type ModalSearchOptions } from "@gleanwork/web-sdk"

const optionalModalSearchOptions: ModalSearchOptions = {
  // ...
}
GleanWebSDK.attach(document.getElementById('search-box'), optionalModalSearchOptions)

// or can import individual methods instead
import { attach, type ModalSearchOptions } from "@gleanwork/web-sdk"
attach(document.getElementById('search-box'), optionalModalSearchOptions)

Script tag

If npm is not a viable solution, you can also integrate Glean via script tag, just include the JS library in the <head> of your page, where YOUR_GLEAN_DOMAIN is where your company accesses Glean, such as app.glean.com, {company}.glean.com.

  <script
    src="https://{YOUR_GLEAN_DOMAIN}/sdk/glean-web-sdk-<version>.min.js"
  ></script>

This will provide all the methods available in NPM package via window.GleanWebSDK, other than that, the usage will remain the same.

Documentation

Details on usage can found on https://developers.glean.com/docs/browser_api/

版本与发布记录

@gleanwork/web-sdk 共发布 13 个版本,首次发布于 2024/05/03;过去 12 个月发布了 3 个版本。

版本发布日期距今
2.5.0latest2026/10/011 个月前
2.4.02026/03/148 个月前
2.3.02026/03/138 个月前
2.3.0-next.0next2025/07/181.3 年前
2.2.0-next.02025/07/181.3 年前
2.2.02025/07/181.3 年前

关于 @gleanwork/web-sdk 的常见问题

@gleanwork/web-sdk 是什么?

Library for embedding Glean UI components

如何安装 @gleanwork/web-sdk?

在项目目录运行 npm install @gleanwork/web-sdk,或使用 pnpm add / yarn add / bun add。

@gleanwork/web-sdk 支持 TypeScript 吗?

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

@gleanwork/web-sdk 支持 ESM 还是 CommonJS?

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

@gleanwork/web-sdk 可以商用吗?

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

@gleanwork/web-sdk 的下载量有多少?

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

@gleanwork/web-sdk 还在维护吗?

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