Skip to content
Pear
Built by Tether

Building Blocks

The Hypercore building blocks are a suite of small, composable JavaScript modules for peer-to-peer data and connectivity. Append-only logs, P2P databases and filesystems, multiwriter, and a global DHT: all running on Bare, all just an npm install away.

They are ordinary modules with the sharp edges sanded off: pick the ones you need, compose them, and ship the same code to desktop, mobile, and the terminal.

The suite

The building blocks at a glance

Seven focused modules. Each does one thing well and hands off to the next. Open the source for any of them on GitHub.

Hypercore

A secure, distributed append-only log, the foundation everything else builds on. Sign once, replicate anywhere, verify on read.

Hyperbee

A B-tree on top of Hypercore: sorted key/value storage with atomic batches, snapshots, and efficient range queries.

Hyperdrive

A real filesystem abstraction. Store files and directories, then replicate them to any peer with sparse, on-demand downloads.

Autobase

Linearize many independent Hypercores into a single deterministic log so multiple peers can write to the same dataset.

Hyperswarm

Find and connect to peers interested in the same topic, with automatic hole-punching and Noise-encrypted connections.

HyperDHT

A distributed hash table keyed by public keys, not IPs. It is the connectivity layer that makes peers reachable from anywhere.

Corestore

A namespace and factory for managing many Hypercores at once, with shared replication and storage.

How they compose

None of these are monoliths. Connectivity sits at the bottom, the signed log in the middle, and your data structures on top. Assemble exactly the system you need.

  1. Your application

    chat, drives, collaborative tools

  2. Hyperbee · Hyperdrive · Autobase

    databases, filesystems, multiwriter

  3. Hypercore · Corestore

    the signed append-only log and management

  4. Hyperswarm · HyperDHT

    peer discovery and connectivity

One codebase

The same code on desktop and mobile

Because the blocks run on Bare, there is no platform-specific fork to maintain. What you write on a laptop is exactly what runs inside a phone or a terminal.

  • Write once

    These are plain JavaScript modules. The Hypercore you create on your laptop is the same one that runs inside a mobile app or a CLI tool.

  • Bare underneath

    Running on Bare means identical behaviour across Linux, macOS, Windows, Android, and iOS, with no native rewrite per platform.

  • Replicate everywhere

    Two peers replicate the same way whether they are two servers, two phones, or a phone and a laptop. The transport is abstracted; your code is not.

In practice

Create a Hypercore, replicate over Hyperswarm

One peer writes blocks and shares its key; another opens the same core read-only and streams it down on demand. No server in between.

  • javascript

    import Hypercore from 'hypercore'
    import Hyperswarm from 'hyperswarm'
    
    // An append-only log, stored locally.
    const core = new Hypercore('./writer-storage')
    await core.ready()
    
    await core.append('hello')
    await core.append('world')
    
    // Join the swarm on the core's discovery key and
    // replicate with every peer we meet.
    const swarm = new Hyperswarm()
    swarm.on('connection', (socket) => core.replicate(socket))
    swarm.join(core.discoveryKey, { server: true, client: true })
    
    console.log('sharing core', core.key.toString('hex'))
  • javascript

    import Hypercore from 'hypercore'
    import Hyperswarm from 'hyperswarm'
    
    // Open the same core by its public key — read-only.
    const clone = new Hypercore('./reader-storage', publicKey)
    await clone.ready()
    
    const swarm = new Hyperswarm()
    swarm.on('connection', (socket) => clone.replicate(socket))
    swarm.join(clone.discoveryKey)
    
    // Blocks download on demand as you read them.
    for (let i = 0; i < clone.length; i++) {
      console.log(i, (await clone.get(i)).toString())
    }

Frequently asked questions

Do I need all of them?
No. Each block is an independent npm package. Many apps use just Hypercore and Hyperswarm; reach for Hyperbee, Hyperdrive, or Autobase only when you need a database, a filesystem, or multiwriter.
How is this different from a normal database?
There is no server. Data lives as signed, append-only logs that any peer can verify and replicate directly. You get the data structures you expect, including key/value, files and multiwriter, without standing up infrastructure.
What is the relationship to Pear?
The building blocks are the data and connectivity layer. Pear, the runtime, CLI and OTA pipeline, packages and ships the apps you build on them. You can use the blocks directly, with or without the Pear platform.
Are they production-ready?
Yes. Hypercore, Hyperswarm, and HyperDHT are stable and power apps like Keet in production. Newer blocks advance from experimental to stable; the module catalog and changelog track each block status.
Can multiple people write to the same data?
A single Hypercore has exactly one writer. For multiwriter, Autobase linearizes many cores into one shared, deterministic log, the basis for collaborative apps and shared databases.
Where is the full reference?
docs.pears.com has guides and per-module API docs, and every block links to its repository on GitHub.

Continue through the stack

The blocks are the data and connectivity layer. Look below them at the runtime, or above them at how apps ship.

  • Bare

    The embeddable JavaScript runtime the building blocks run on.

    Explore now
  • Pear Runtime & CLI

    Package and ship apps built on the blocks, with over-the-air updates.

    Explore now

Build with the blocks

Compose append-only logs, P2P databases, and a global DHT into your own peer-to-peer app.