@webbtc/webln-types
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

webln-types

Type definitions for WebLN

WebLN may be implemented by a lightning browser extension (e.g. Alby) therefore WebLN can already be called directly from the browser if the user has the extension installed. This package simply adds type definitions to make it easier to integrate WebLN into web applications that are written in Typescript.

Quick Start

  1. Install package

    npm install @webbtc/webln-types --save-dev # or yarn add @webbtc/webln-types --dev
  2. Create webln-types.d.ts in your src directory with the following contents to ensure the types are picked up by the Typescript compiler:

/// <reference types="@webbtc/webln-types" />
  1. Import types from "@webbtc/webln-types"
import type { GetInfoResponse } from "@webbtc/webln-types";

if (window.webln) {
  (async () => {
    await window.webln.enable();
    const info: GetInfoResponse = await window.webln.getInfo();
    console.log("Your node pubkey is", info.node.pubkey);
  })();
} else {
  console.warn("WebLN not enabled");
}

Adding WebLN to your application

Read the WebLN Guide

Package Sidebar

Install

npm i @webbtc/webln-types

Weekly Downloads

1,048

Version

3.0.0

License

MIT

Unpacked Size

12 kB

Total Files

5

Last publish

Collaborators

  • reneaaron
  • bumi
  • rolznz