New JavaScript API for lightning web applications
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.
Have a look at the full code on Replit: React app for LND or the React app for CLN
But 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!