Files
BridgeSwarm/examples/sync-demo/README.md
T
Raven Scott 1bc6f445ac
CI / Build & Test (push) Successful in 10m34s
Updates
2026-08-12 17:01:57 -04:00

1.3 KiB

Auto-replicate — Hypercore sync on new connections

What this example does

Turns on swarm.setAutoReplicate({ enabled: true }) so every new Hyperswarm connection is taken over by the host for Hypercore replication. Append blocks in one tab and watch core.length grow in the other.

Those sockets are not usable for page chat or in-page Protomux while auto-replicate is on.

Prerequisites

Install the BridgeSwarm extension and native host.

How to run

Recommended: Extension Settings → enable Examples server.

npm run examples

Open http://127.0.0.1:4173/sync-demo/ in two tabs. Do not use file://.

Usage

  1. Join the same topic in both tabs.
  2. Enable auto-replicate.
  3. Append text in one tab.
  4. Click Core info in the other — length should increase after the cores replicate.

Files in this directory

  • index.html — Topic, auto-replicate toggles, append, log.
  • style.css — Layout.
  • app.js — Swarm session, setAutoReplicate, coreAppend / coreInfo.

APIs and concepts

  • swarm.setAutoReplicate({ enabled, coreKeyHex?, resourceId? })
  • attachReplication (what auto-replicate runs per connection)
  • Default Hypercore name 'default'

See Data API.