@badge-sdk/web

中文文档
0.4.1发布于 2026/08/26MITTypeScriptESM + CJS近 30 天下载 2.2万

Embed Badge's mobile wallet management features within your existing application.

原始使用文档
文档目录6 节
  1. What is Badge?
  2. Who uses Badge?
  3. Usage
  4. Bundler Support
  5. Browser Support
  6. License

@badge-sdk/web

@badge-sdk/web allows you to to embed Badge's Mobile Wallet management features within your web application. For full SDK documentation visit: https://docs.trybadge.com/docs/sdk

For information on the Badge platform, check out our website and docs.

What is Badge?

Badge, enables platforms to embed a version of Badge's no-code UI in your web application or SaaS platform to enable mobile wallets for your customers.

With Badge, you can provide your customers access to pass editing, management, metrics, and campaigns without leaving your your product.

Who uses Badge?

Badge is built for businesses of all sizes that want to leverage the power of mobile wallets.

Whether you're a small business looking to enhance the customer experience or a large enterprise seeking to drive new revenue streams, Badge provides the tools and flexibility to achieve your goals.

We offer the customization options and support to create tailored wallet experiences that align perfectly with your brand, industry, and specific marketing objectives.

Usage

In order to use the SDK you need a Badge Workspace and an SDK Token.

With the SDK Token the Badge SDK can be initialized:

import * as badge from "@badge-sdk/web";

const badgeSdk = badge.makeSdk({token: badgeToken});

The SDK can now be used to embed a pass template:

<div id="badge-template" style="height:100%">Loading...</div>
badge.embedTemplatePage(
  badgeSdk,
  window.document.getElementById("badge-template"),
  {
    templateId: templateId,
    features: {
      passList: true,
      templateEditor: true,
    },
  },
);

There are various features that can be enabled by setting attributes in features. Additional details can be found in the SDK config doc.

The appearance of the embed can also be customized. Additional details can be found in the SDK config doc.

Bundler Support

The package ships both an ES module (dist/index.js) and a UMD build (dist/index.umd.cjs), with all dependencies bundled. Bundled TypeScript declarations are included, so no separate @types package is needed.

A bundler is not required. The UMD build can be loaded directly from a script tag via any npm CDN, which exposes the SDK as the global badge:

<script src="https://unpkg.com/@badge-sdk/web"></script>
<script>
  const badgeSdk = badge.makeSdk({token: badgeToken});
</script>

Browser Support

The SDK is published as ES2020 and supports the following minimum browser versions:

  • Chrome 87+
  • Edge 88+
  • Firefox 78+
  • Safari 14+ (including Safari on iOS 14+)

Chromium-based browsers such as Opera, Brave, and Samsung Internet are supported from the release that corresponds to Chrome 87. Older browsers require your own transpilation and polyfills.

License

This repository is MIT licensed.

版本与发布记录

@badge-sdk/web 共发布 10 个版本,首次发布于 2025/01/18;过去 12 个月发布了 3 个版本。

版本发布日期距今
0.4.1latest2026/08/262 个月前
0.4.02026/08/152 个月前
0.3.02026/02/039 个月前
0.2.02025/06/271.4 年前
0.1.12025/05/031.5 年前
0.1.02025/05/011.5 年前

其他发布通道:alpha → 0.1.0-alpha.3。

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

@badge-sdk/web 是什么?

Embed Badge's mobile wallet management features within your existing application.

如何安装 @badge-sdk/web?

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

@badge-sdk/web 支持 TypeScript 吗?

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

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

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

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

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

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

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

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

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