Articles /Pin to ProfileBookmark

New JavaScript API for lightning web applications

Dec 28, 2022  •  @getalby  •  5,000
Copy linkTweet this

Beyond offering powerful tools for instant, effortless compensation, Alby presents exciting opportunities for those developing lightning web apps.

💥 TL;DR

  • Easy access to all lightning node APIs via a JavaScript interface (node info, channel infos, balances, fee reports, etc.) for web apps
  • It’s now possible to build the next node management app as a client-side JavaScript application 🤯

Let’s dive into how the Alby Extension is helping web developers create an exciting new era of lightning apps.

Lightning web apps with client side JavaScript

With WebLN the Alby Extension already exposes an API to allow web apps to call functionalities from bitcoin lightning wallets.

As an established standard it describes a set of specifications for lightning apps and client providers to facilitate communication between web apps and users’ lightning wallets in a secure way. It provides a programmatic, permissioned interface for letting applications ask users to send payments and generate invoices and more.

During the community calls of the WebBTC specification group on improving and expanding WebLN there have been discussions on allowing web apps to also access more lightning node functionalities. For this the webln.request() method was introduced. With the latest Alby update we completed the implementation of this proposal in the Alby Extension.

The Alby Extension now allows developers to perform calls to the user’s connected node backend through a simple JavaScript interface. This makes it possible to build rich lightning applications with web technologies and as full client-side applications.

Developers can easily access any node APIs without having to deal with the complexities of connecting to the node or the underlying protocol. Loading the lightning channels from LND (listchannels API) is now a function call away: webln.request('listchannels')

Users can bring their own node connection to web applications without having to pass their node credentials, without installing additional node software or having to jump loops to access nodes behind TOR or only offering RPC APIs.Alby provides fine-grained access control and puts the user in full control.

Enabling completely new use cases

Full node API access for endless possibilities. Now developers can for example build web apps:

  • Visualize channels and balances. Maybe combined with some node data with the Amboss API?
  • Selling channels to those needing inbound liquidity
  • Provide re-balancing services
  • Offer swap services
  • Recommend fees for channels
  • … What do you want to build?

Have a look at our demos

To showcase some of the possibilities we have developed a quick React demo application with a simple node dashboard and channel management.

Liquimercado showcase video: https://www.youtube.com/watch?v=Zeu2lrO7XzE&t

Have a look at the full code on Replit: React app for LND or the React app for CLNBut here is the “hello world” code to list channels and open a new channel with a connected LND node:

Yes, that’s all the code that you need.

Try out these showcases and check out the example code in the React apps

And now creativity is needed. With WebLN/WebBTC Alby enables the application layer where new types of web applications can thrive. It will be exciting to see what developers will build to improve the lightning experience. We invite everyone; developers, designers, and tinkerers to experiment and make use of these new features. Let’s build on the lightning network!

Do you have an idea? Let us know. Don’t hesitate to contact us directly if you have more questions: We would love the opportunity to talk about how we can help you start building your bitcoin app on the web. That’s why we create dedicated office hours. Book a slot with us and let’s chat! We are looking forward to speaking with you and helping you build and succeed!

Originally published on https://blog.getalby.com/start-building-the-next-era-of-lightning-apps/

Front-endJavaScript
This article was originally published on blog.getalby.com
×

Success!

Help @getalby spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with Github
about: ({
version: 0.1.7 BETA 2.4,
whats_new: article editor v2,
up_next: tip code demos,
coming_soon: embeddable tipping,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh

version: 0.1.5,
notes: added pins + new badge

version: 0.1.4,
notes: home refresh + tools
)...
recent_tips: (
tipper: @JohnDavis,
amount: 250 SATS,
source: article

tipper: @Megan0910,
amount: 1000 SATS,
source: article

tipper: @JohnDavis,
amount: 250 SATS,
source: article
)...