@braze/service-worker

中文文档
7.1.0发布于 2026/10/15SEE LICENSE IN https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSECommonJS零依赖近 30 天下载 6.5万

Braze service worker to be used with the Braze Web SDK.

原始使用文档

Install

$ npm install --save @braze/web-sdk
$ npm install --save @braze/service-worker

This will install the Braze Service Worker files into ./node_modules/@braze/service-worker where you can reference them locally. Note that the Braze Service Worker is only meant to be used along with the Braze Web SDK.

Usage

In your build process, copy node_modules/@braze/service-worker/service-worker.js to your web application's public root directory.

Then, using the Web SDK, provide the serviceWorkerLocation initialization option with the path to your service worker.

See our documentation pages for steps to integrate push notifications into your website using the Braze Web SDK.

版本与发布记录

@braze/service-worker 共发布 81 个版本,首次发布于 2020/06/09;过去 12 个月发布了 17 个版本。

版本发布日期距今
7.1.0latest2026/10/1524 天前
7.0.02026/10/031 个月前
6.13.02026/09/121 个月前
6.12.12026/09/101 个月前
6.12.02026/09/032 个月前
6.11.02026/08/212 个月前

关于 @braze/service-worker 的常见问题

@braze/service-worker 是什么?

Braze service worker to be used with the Braze Web SDK.

如何安装 @braze/service-worker?

在项目目录运行 npm install @braze/service-worker,或使用 pnpm add / yarn add / bun add。

@braze/service-worker 支持 TypeScript 吗?

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

@braze/service-worker 支持 ESM 还是 CommonJS?

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

@braze/service-worker 可以商用吗?

@braze/service-worker 使用 SEE LICENSE IN https://github.com/braze-inc/braze-web-sdk/blob/master/LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@braze/service-worker 的下载量有多少?

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

@braze/service-worker 还在维护吗?

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