Webxdc (Psst!) reclaiming Peer-to-Peer Web technology

February 15, 2024 by olgax

Webxdc Logo While blockchain projects hailed “decentralization” and “Web3” as a paradigm change, expending billions of dollars and development hours in the last decade, they failed to create even a baseline specification for packaging and running P2P web apps like the one we started in 2022 with webxdc.

webxdc apps are HTML5 app container files which use a simple send/receive APIs provided by a supporting messenger. A webxdc app does not need to implement, and does not depend on, any transport mechanism or messenger stack in particular. It also does not need to implement onboarding and peer discovery because all apps run on an already established chat-group context, tapping into the pre-existing user experience of billions of users.

Learning how to program P2P webxdc apps

Webxdc app development is radically easier than developing for and maintaining an application-specific always-online HTTP server. But there are undeniably complications in arranging consistent web app state across user’s devices, a typical issue for any P2P networking system. The new Shared Web Application State chapter walks you through theory and practise of so called “conflict-free replicated data types” (CRDTs). This new app-developer focused chapter was created by ansuz also known for his lead development role at Cryptpad for many years. The confluence of E2EE and P2P expertise is less surprising if you consider that any end-to-end encrypting application can not rely on a central authority to resolve conflicts and “tell the truth”.

Pixel: minimal CRDT-implementation for collaborative pixel-drawing (2.8 KB)

a screenshot of pixel.xdc, the pixels show a rocket.

Writing a webxdc app that offers a consistent user experience can be done in few code and without relying on any dependencies. The Pixel app allows to set and clear pixels for anyone in a chat, and it resolves any concurrency conflicts by using “Lamport Clocks”. It does that in 150 lines of plain Javascript code proving that CRDTs are fundamentally less complex than you might think.

A basic cross-platform Editor using Prosemirror and Yjs (148KB)

a screenshot of editor.xdc, it shows example text.

In around 400 lines of Code, the webxdc/editor implements an end-to-end encrypting offline-first editor that you can use in any chat group to jointly edit a document. The editor uses the y-webxdc provider which integrates webxdc’s send/receive API with Yjs, a popular Javascript implementation for Conflict-free-Replicable-Data-Types (CRDTs).

Checklist: Javascript app using automerge (98 KB)

a screenshot of checklist.xdc, showing example to do list items.

People use checklist for shopping lists or preparing family travels every day. checklist app uses automerge, another interesting CRDT implementation effort. Note that webxdc does not prescribe any particular framework or data types for how apps arrange a distributed consistent user experience.

More apps with “View Source”

The new webxdc.org/apps page provides a straightforward search and download interface – you may attach a downloaded file to a chat message, enabling chat-group members to run the app without them having to download anything themselves. A running app offers a “View Source” option that directly gets you to the development repository. Collaboration and forking welcome!

A screenshot of xstore, opened in Delta Chat. In a "help" context menu, you can view the source code.

Longevity and hassle-free creation and use of webxdc apps

Webxdc apps can be written once and require no hosting, accounting, registration or compliance work. They are private by design and architecture and thus require no GDPR policies or cookie consent. The first 2022 webxdc apps run unmodified on today’s Delta Chat and Cheogram messengers, as well as on any potential other messaging project adopting the straight forward webxdc specification, which now has good table-of-content markers to ease navigation. But no worries, it’s still a very small spec you can read in a quarter hour :)

Getting started developing your own app

The refined development docs page now begins with a “getting-started” page that allows to create and run your first web app within minutes.

Psst, interested to move P2P web apps forward with us?

There are many interesting webxdc developments evolving for 2024, not the least because of crucial funding support from NLNET who administers much of the EU’s Next-Generation-Internet (NGI) funds, and recognizes webxdc as a promising technology and specification.

While we generally do not pre-announce our release planning we already integrated Iroh for multi-device setup support and have evolving experimental branches to let webxdc apps use realtime P2P communication by means of Iroh.network, a well-done Rust port of tailscale which in turn is a proven and well functioning existing P2P networking and holepunching stack. We regard Iroh to be one of the most interesting efforts to arise out of the ashes of Web3. Note that webxdc app developers will still just use send/receive APIs and are neither dependent nor need to involve themselves with the integration of deltachat-core-rust and Iroh.network. Other messengers may use different ways to provide P2P connectivity for apps.

While Delta Chat developers co-evolve the webxdc spec and implementations, they typically focus on releasing Delta Chat native messenger apps on all platforms and stores. Developing webxdc apps themselves only happens on the “side”. This is not meant to say anything against doing a little app on the side! In fact, there is a carpenter by trade among us who freshly learned HTML and Javascript and already has published three apps in the store :)

However, more experience and focus on user-facing web apps, including improving tooling and example apps, driving new webxdc API designs from real-world needs, helping newcomers etc. would be very welcome and greatly needed to help all evolving efforts. If you are interested, or know someone who might be interested, also in a paid contract to help, an earlier post provides more social background. Feel free to get in touch maybe also by submitting an app to indicate you are serious or playful – ported casual games are also always welcome! :)

Picture of Delta Chat contributors in party in Kyiv


Show Comments


You can reply on any Fediverse (Mastodon, Pleroma, etc.) website or app by pasting this URL into the search field of your client:

https://chaos.social/@delta/111935038589329716