Dweb: Serving the Web from the Browser with Beaker

In this series we are covering projects that explore what is possible when the web becomes decentralized or distributed. These projects aren’t affiliated with Mozilla, and some of them rewrite the rules of how we think about a web browser. What they have in common: These projects are open source, and open for participation, and share Mozilla’s mission to keep the web open and accessible for all.

So far we’ve covered distributed social feeds and sharing files in a decentralized way with some new tools for developers. Today we’d like to introduce something a bit different: Imagine what an entire browser experience would be like if the web was distributed… Beaker browser does exactly this! Beaker is a big vision from a team who are proving out the distributed web from top to bottom. Please enjoy this post from Beaker co-creator Tara Vancil. – Dietrich Ayala


Blue Link Labs and Beaker

We’re Blue Link Labs, a team of three working to improve the Web with the Dat protocol and an experimental peer-to-peer browser called Beaker.

Blue Link Labs team

We work on Beaker because publishing and sharing is core to the Web’s ethos, yet to publish your own website or even just share a document, you need to know how to run a server, or be able to pay someone to do it for you.

So we asked ourselves, “What if you could share a website directly from your browser?”

Peer-to-peer protocols like dat:// make it possible for regular user devices to host content, so we use dat:// in Beaker to enable publishing from the browser, where instead of using a server, a website’s author and its visitors help host its files. It’s kind of like BitTorrent, but for websites!

Architecture

Beaker uses a distributed peer-to-peer network to publish websites and datasets (sometimes we call them “dats”).

dat:// websites are addressed with a public key as the URL, and each piece of
data added to a dat:// website is appended to a signed log. Visitors to a dat://
website find each other with a tracker or DHT, then sync the data between each other, acting both as downloaders and uploaders, and checking that the data hasn’t been tampered with in transit.

a basic illustration of the dat:// network

At its core, a dat:// website isn’t much different than an https:// website — it’s a collection of files and folders that a browser interprets according to Web standards. But dat:// websites are special in Beaker because we’ve added peer-to-peer Web APIs so developers can do things like read, write, and watch dat:// files and build peer-to-peer Web apps.

Create a P2P Website

Beaker makes it easy for anyone to create a new dat:// website with one click (see our tour). If you’re familiar with HTML, CSS, or JavaScript (even just a little bit!) then you’re ready to publish your first dat:// website.

Developers can get started by checking out our API documentation or reading through our guides.

This example shows a website editing itself to create and save a new JSON file. While this example is contrived, it demonstrates a common pattern for storing data, user profiles, etc. in a dat:// website—instead of application data being sent away to a server, it can be stored in the website itself!

// index.html

Submit message

<script src="index.js"></script>

// index.js

// first get an instance of the website's files
var files = new DatArchive(window.location)

document.getElementById('create-json-button').addEventListener('click', saveMessage)

async function saveMessage () {
var timestamp = Date.now()
var filename = timestamp + '.json'
var content = {
timestamp,
message: document.getElementById('message').value
}

// write the message to a JSON file
// this file can be read later using the DatArchive.readFile API
await files.writeFile(filename, JSON.stringify(content))
}

Learn More

We’re always excited to see what people build with dat:// and Beaker. We especially love seeing when someone builds a personal site or blog, or when they experiment with Beaker’s APIs to build an app.

There’s lots to explore on the peer-to-peer Web!

About Tara Vancil

Tara is the co-creator of the Beaker browser. Previously she worked at Cloudflare and participated in the Recurse Center.

More articles by Tara Vancil…


8 comments

  1. Ibon

    Nice article: people centered technologies (instead of “cloud” ones) are so interesting! :)

    August 23rd, 2018 at 03:53

  2. Pseudo Blüm

    I really love your series on the dweb, yet I have to say that I get kinda confused on how all these relate.

    Are they all (beaker, zeronet, webTorrent, bitTorrent, etc.) only using the same principle of P2P, or is there a bigger correlation than that.

    For instance it would interest me, if you could view a zeronet website via beaker, or if dat:// websites could somehow be retrieved via webTorrent.

    Thanks for all these great articles
    Pseudo Blüm

    August 23rd, 2018 at 13:04

    1. Tara Vancil

      Hi Pseudo!

      >  I have to say that I get kinda confused on how all these relate

      I think this series is aiming to highlight different projects in the P2P space, because even though they use different underlying technologies, they often have similar goals and use similar techniques to achieve them.

      It’s like the difference between http:// and ftp://. They have some things in common, but they’re used differently and support different features. Beaker only supports dat:// and dat:// has some things in common with WebTorrent, but at the end of the day they’re different protocols.

      With all this experimentation happening on the dweb/p2p web, it’ll be interesting to see how it all looks in 5 years :-)

      August 29th, 2018 at 10:49

  3. Thorsten

    A) Is dat:// secure like https:// ?
    B) With this technology, could a search-engine like YaCy become part of a browser/webextension? It would be awesome if we could bypass google Et. al simply by running enough firefoxes. Getting recommendations without refering to an external database could also greatly improve the datatrail we leave.

    August 28th, 2018 at 06:31

    1. Tara Vancil

      Hi Thorsten! Thanks for the questions.

      > Is dat:// secure like https:// ?

      I try to be careful about how I use the word “secure” since it can be interpreted in so many different ways, but to answer your specific question, yes, dat:// shares the same security-related characteristics as https://

      1. Like https://, data transported with dat:// is authenticated. This means that when I visit a dat:// URL, I know that the files I download haven’t been tampered with in-transit.
      2. Like https://, data is encrypted in-transit. So if someone is snooping on your internet traffic, they’ll only see the encrypted content, not the raw data.

      > With this technology, could a search-engine like YaCy become part of a browser/webextension?

      Possibly! But it’s hard to say for sure. We’re familiar with YaCy and will continue keeping an eye on their work :-)

      August 29th, 2018 at 10:17

  4. John

    Hi

    This is really REALLY AWESOME!!!

    I gave it a try and was positively impressed! (I just missed a good-old bookmarks’ bar…)

    As far as i can tell, this is based on Chromium, right?
    Would be nice to see this based on Firefox instead (or even in QtWebEngine… even that being based on chromium……… just not something “googled”).

    Would be great to see Mozilla having similar technologies in Firefox :)

    Continue your great work :)

    September 10th, 2018 at 10:32

    1. Tara Vancil

      Hey John! I’m glad to you tried Beaker! We’ve been thinking about adding a proper bookmark bar, but you know how things go, roadmaps and TODO lists grow quickly :-)

      And yep, Beaker is built with Electron, which is Chromium-based. We think it would be awesome to build Beaker on different engines, but at the moment, Electron is the only tool that makes it possible for a small team like us to build a browser. Cheers!

      September 10th, 2018 at 13:09

  5. pawel

    hi,
    Can you point me to more information
    A) how content is indexed and searched?
    B) what happens if my laptop is down and nobody else has a copy of my page? Will a reader have an info that this content is not available yet but may come soon?
    C) what happens if there are more than one version of my page is there information that you may see stale data? how other peers realise that there might be a new version, can author control that, or at least list all copies and their version?

    thanks

    September 17th, 2018 at 01:09

Comments are closed for this article.