Wavelength SDK
A TypeScript SDK for embedding a self-custodial Lightning wallet directly in
your app, on the web and on mobile. Your users send and receive Lightning
payments with no node to run, no channels to open, and no inbound liquidity to
manage, while the keys stay on their own device. The wallet runs entirely
in-process: as WebAssembly in the browser, or as a native module compiled into
a React Native app. There is no backend to operate and nothing listening on a
socket; your app drives the wallet through a small, typed client.
Full documentation lives at
wavelength.lightning.engineering.
How it fits together
The SDK is a typed client over the
wavelength wallet daemon, which
is compiled to WebAssembly for the browser and via gomobile for iOS and
Android. The SDK loads that runtime and exposes it as the WavelengthClient
contract plus a framework-agnostic WalletEngine.
Each SDK release pairs with a pinned wavelength release (the
RUNTIME_MANIFEST_VERSION that @lightninglabs/wavelength-core exports).
That release is where the runtime artifacts come from: the wasm asset set for
the web and the native binaries for React Native. See
Runtime assets and native bindings.
Packages
wavelength-web and wavelength-react-native each re-export every type from
core, so an app imports the client and its types from one place.
Apps
None of these are published; they live in the repository as reference code and
verification harnesses.
Install
# React on the web (the binding + the web transport)
npm install @lightninglabs/wavelength-react @lightninglabs/wavelength-web
# React Native (the binding + the native transport)
npm install @lightninglabs/wavelength-react @lightninglabs/wavelength-react-native
# Vanilla / Vue / Svelte (web transport only)
npm install @lightninglabs/wavelength-web
You build the engine with createWebWalletEngine() from wavelength-web or
createNativeWalletEngine() from wavelength-react-native. In React you pass
that engine to WavelengthProvider; the provider itself is transport-agnostic
and works the same way with either.
Quickstart: web
import {
WavelengthProvider,
useWallet,
useWalletBalance,
useWalletSend,
} from "@lightninglabs/wavelength-react";
import { createWebWalletEngine, defaultConfig } from "@lightninglabs/wavelength-web";
// Build the engine once. runtimeBaseUrl points at the hosted wasm runtime
// assets (see below). config + autoStart boot the embedded wallet as soon as
// the wasm runtime is ready.
const engine = createWebWalletEngine({
runtimeBaseUrl: "https://your-host/wavewalletdk/",
config: defaultConfig("signet"),
autoStart: true,
});
function Root() {
return (
<WavelengthProvider engine={engine}>
<Wallet />
</WavelengthProvider>
);
}
function Wallet() {
const { phase } = useWallet();
const balance = useWalletBalance();
const { send } = useWalletSend();
if (phase !== "ready") return <p>Loading… ({phase})</p>;
return (
<div>
<p>Spendable: {balance?.confirmedSat ?? 0} sats</p>
<button onClick={() => send({ invoice: "lnbc…" })}>Pay</button>
</div>
);
}
Focused hooks are available when you only need a slice. State-reading hooks
like useWalletBalance() and useWalletActivity() return their value directly.
Mutation hooks like useWalletSend(), useWalletReceive(), and useWalletDeposit()
each expose an action plus verb-prefixed state, e.g. useWalletSend() returns
{ send, sendPending, sendError, sendData, resetSend }.