Files
BridgeSwarm/examples/data-demo
Raven Scott 906422d0a5
CI / Build & Test (push) Successful in 8m12s
Updates
2026-07-26 23:23:52 -04:00
..
2026-07-26 23:23:52 -04:00
2026-07-26 23:23:52 -04:00
2026-07-26 22:19:31 -04:00
2026-07-26 23:23:52 -04:00

Data API Demo — Hypercore, Hyperbee, Hyperdrive, Autobase, Hyperdb

What this example does

Uses the native host Data API via BridgeSwarm.request(type, payload): Hypercore (info, append, get), Hyperbee (put/get/del), Hyperdrive (put/get/list), Autobase (append, info, view), and Hyperdb (insert/get/delete/find/flush on the records collection). Single tab; no P2P connections required for basic operations.

Prerequisites

Install the BridgeSwarm extension and native host before opening this example.

How to run

npm run examples

Open http://127.0.0.1:4173/data-demo/. Do not use file://.

Usage

  1. Open the page; the log shows “Data API ready” when the extension is available.
  2. Use the buttons to run each command: Core info, Append; Put / Get / Del for Hyperbee; Put / Get / List / for Hyperdrive; Append / Info / Read view (0..4) for Autobase; Put / Get / Del / Find all / Flush for Hyperdb (records).
  3. The log shows request results and errors.

Files in this directory

  • index.html — Page structure (sections and buttons per API, log).
  • style.css — Layout and theme (sections, rows, log).
  • app.js — BridgeSwarm.ready(), BridgeSwarm.request() for each command type, log output.

APIs and concepts

  • BridgeSwarm.ready() — Wait for the injected API.
  • BridgeSwarm.request(type, payload) — Send a command to the host. Types used:
    • Hypercore: coreInfo, coreAppend, coreGet
    • Hyperbee: beeGet, beePut, beeDel
    • Hyperdrive: driveGet, drivePut, driveList
    • Autobase: autobaseAppend, autobaseInfo, autobaseViewGet
    • Hyperdb: hyperdbInsert, hyperdbGet, hyperdbDelete, hyperdbFindToArray, hyperdbFlush (collection records)

Responses are { ok, ... } or { ok: false, error }; binary data is base64 in payloads.

See also