Hypercore
A secure, distributed append-only log, the foundation everything else builds on. Sign once, replicate anywhere, verify on read.
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
Seven focused modules. Each does one thing well and hands off to the next. Open the source for any of them on GitHub.
A secure, distributed append-only log, the foundation everything else builds on. Sign once, replicate anywhere, verify on read.
A B-tree on top of Hypercore: sorted key/value storage with atomic batches, snapshots, and efficient range queries.
A real filesystem abstraction. Store files and directories, then replicate them to any peer with sparse, on-demand downloads.
Linearize many independent Hypercores into a single deterministic log so multiple peers can write to the same dataset.
Find and connect to peers interested in the same topic, with automatic hole-punching and Noise-encrypted connections.
A distributed hash table keyed by public keys, not IPs. It is the connectivity layer that makes peers reachable from anywhere.
A namespace and factory for managing many Hypercores at once, with shared replication and storage.
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.
chat, drives, collaborative tools
databases, filesystems, multiwriter
the signed append-only log and management
peer discovery and connectivity
One codebase
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.
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.
Running on Bare means identical behaviour across Linux, macOS, Windows, Android, and iOS, with no native rewrite per platform.
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
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())
}The blocks are the data and connectivity layer. Look below them at the runtime, or above them at how apps ship.
Compose append-only logs, P2P databases, and a global DHT into your own peer-to-peer app.