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

1.6 KiB

Local Power — fs, sqlite, net

What this example does

Exercises the host-side capability packs that give the page allowlisted local power:

  • fs — read / write / list / delete under BRIDGE_SWARM_STORAGE/files/
  • sqlite — open a database under BRIDGE_SWARM_STORAGE/sqlite/, exec and query
  • net — CORS-free public http(s) fetch (private / loopback / metadata hosts blocked)

No P2P topic is required.

Prerequisites

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

How to run

Recommended: Extension Settings → enable Examples server, then open the demo URL below.

Dev alternative from the repo root:

npm run examples

Open http://127.0.0.1:4173/local-power/. Do not use file://.

Usage

  1. Confirm the banner lists fs, sqlite, and net.
  2. Files: write hello.txt, read it back, list the tree, delete.
  3. SQLite: open demo, exec CREATE TABLE …, change the SQL to SELECT * FROM notes, query.
  4. Fetch: request https://example.com (text) or a public JSON URL. http://127.0.0.1/ must fail.

Files in this directory

  • index.html — Tabs for Files / SQLite / Fetch.
  • style.css — Small layout extras on shared chrome.
  • app.jsBridgeSwarm.fs / .sqlite / .net calls.

APIs and concepts

  • BridgeSwarm.capabilities.list() — installed pack ids.
  • BridgeSwarm.fs.write/read/list/unlink
  • BridgeSwarm.sqlite.open/exec/query/close
  • BridgeSwarm.net.fetch({ url, as })

See Capabilities.