WebLN Guide
Ask or search…
K
🆕

webln.on()

This method specifically allows you to listen for a particular event such as "accountChanged" and execute a callback function when this event occurs.
This API may not be available on all providers.

Method

function on(eventName: "accountChanged", listener: () => void): void;

Code Example

if (!webln.on) { alert('not supported'); }
await webln.enable();
webln.on("accountChanged", accountChangedHandler); // callback is executed once account is changed in provided with multiple accounts
function accountChangedHandler() {
console.log("Account Changed!");
}

Demo

Last modified 6mo ago