@breeztech/breez-sdk-spark

中文文档
0.28.0发布于 2026/11/05MITTypeScriptESM + CJS零依赖近 30 天下载 4.1万

Breez Spark SDK

原始使用文档
文档目录10 节
  1. Overview
  2. What is the Breez SDK?
  3. Installation
  4. Usage
  5. Web
  6. SSR Frameworks (Next.js, SvelteKit, Nuxt, Remix)
  7. Node.js
  8. Subpath Exports
  9. Pricing
  10. Support

Breez SDK

Overview

The Breez SDK provides developers with an end-to-end solution for integrating instant, non-custodial bitcoin and stablecoins into their apps and services. It eliminates the need for third parties, simplifies the complexities of Bitcoin and Lightning, and enables seamless onboarding for billions of users to the future of value transfer.

What is the Breez SDK?

It’s a nodeless integration that offers a non-custodial, end-to-end solution for integrating bitcoin and stablecoins, utilizing the Bitcoin-native Layer 2 Lightning & Spark, with on-chain interoperability and third-party fiat on-ramps.

Installation

To install the package:

npm install @breeztech/breez-sdk-spark

or

yarn add @breeztech/breez-sdk-spark

Usage

Head over to the Breez SDK documentation to start implementing instant bitcoin and stablecoins in your app or service.

Web

When developing a browser application, import from @breeztech/breez-sdk-spark (or the explicit @breeztech/breez-sdk-spark/web subpath).

Call await init() to load the WebAssembly module before using any other SDK methods.

import init, {
  defaultConfig,
  connect,
} from "@breeztech/breez-sdk-spark/web";

await init();

const config = defaultConfig("mainnet");
config.apiKey = "<your api key>";

const sdk = await connect({
  config,
  seed: { type: "mnemonic", mnemonic: "<words>", passphrase: undefined },
  storageDir: "./.data",
});

SSR Frameworks (Next.js, SvelteKit, Nuxt, Remix)

Use the @breeztech/breez-sdk-spark/ssr subpath in SSR applications. It can be imported during server-side rendering without errors — no WASM is loaded, no browser or Node.js APIs are touched. Call init() on the client to load the WASM module before using SDK functions.

"use client";
import { useEffect, useState } from "react";
import init, { connect, defaultConfig } from "@breeztech/breez-sdk-spark/ssr";

export default function Wallet() {
  const [sdk, setSdk] = useState(null);

  useEffect(() => {
    (async () => {
      await init(); // Loads WASM — client-side only
      const config = defaultConfig("mainnet");
      config.apiKey = "<your api key>";
      const s = await connect({
        config,
        seed: { type: "mnemonic", mnemonic: "<words>", passphrase: undefined },
        storageDir: "./.data",
      });
      setSdk(s);
    })();
  }, []);

  return <div>{sdk ? "Connected" : "Loading..."}</div>;
}

Node.js

Note: This package requires Node.js v22 or higher.

When developing a Node.js application, use require("@breeztech/breez-sdk-spark") or import from it (or the explicit @breeztech/breez-sdk-spark/nodejs subpath). No init() call is needed: the WASM module loads automatically.

const {
  defaultConfig,
  connect,
} = require("@breeztech/breez-sdk-spark");

const config = defaultConfig("mainnet");
config.apiKey = process.env.BREEZ_API_KEY;

const sdk = await connect({
  config,
  seed: { type: "mnemonic", mnemonic: process.env.MNEMONIC, passphrase: undefined },
  storageDir: "./.data",
});

const info = await sdk.getInfo({});
console.log(`Balance: ${info.balanceSats} sats`);

Subpath Exports

SubpathEnvironmentModule Format
@breeztech/breez-sdk-sparkNode.js / Browser (default)CJS / ESM
@breeztech/breez-sdk-spark/webBrowserESM
@breeztech/breez-sdk-spark/nodejsNode.jsCJS / ESM
@breeztech/breez-sdk-spark/bundlerBundler (Webpack, Vite)ESM
@breeztech/breez-sdk-spark/denoDenoESM
@breeztech/breez-sdk-spark/ssrSSR (explicit)ESM

Pricing

The Breez SDK is free for developers.

Support

Have a question for the team? Join us on Telegram or email us at [email protected].

版本与发布记录

@breeztech/breez-sdk-spark 共发布 148 个版本,首次发布于 2025/08/26;过去 12 个月发布了 109 个版本。

版本发布日期距今
0.28.0latest2026/11/053 天前
0.27.3-dev2026/11/053 天前
0.27.22026/10/2316 天前
0.27.12026/10/2317 天前
0.27.02026/10/2217 天前
0.26.12026/10/021 个月前

关于 @breeztech/breez-sdk-spark 的常见问题

@breeztech/breez-sdk-spark 是什么?

Breez Spark SDK

如何安装 @breeztech/breez-sdk-spark?

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

@breeztech/breez-sdk-spark 支持 TypeScript 吗?

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

@breeztech/breez-sdk-spark 支持 ESM 还是 CommonJS?

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

@breeztech/breez-sdk-spark 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@breeztech/breez-sdk-spark 可以商用吗?

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

@breeztech/breez-sdk-spark 的下载量有多少?

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

@breeztech/breez-sdk-spark 还在维护吗?

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