Pp2pbuilders
learn › Holepunch walkthroughs

6 min read · also at #/learn/hp-bare

Bare: the small JS runtime

Bare is a minimal JavaScript runtime:
V8 plus a tiny native core, with everything else — fs, tcp, tty, crypto —
shipped as addon modules instead of baked in. It is what Pear terminal
apps and mobile embeddings actually run on.

Why it matters for P2P:

the same backend that powers your desktop node runs on a phone.

stays tiny.

Node-compatible-ish, by choice

Bare mirrors Node's module shapes (bare-fsfs, bare-process
process, …). The trick for code that runs on both is conditional
imports in package.json:

"imports": {
  "#fs":      { "bare": "bare-fs",      "default": "./shims/node-fs.js" },
  "#process": { "bare": "bare-process", "default": "./shims/node-process.js" }
}

Then require('#fs') resolves to the right implementation per runtime.
p2pbuilders isolates every platform touchpoint behind one _rt.js shim —
that single decision is why the same backend boots under Node, Pear and
bare-kit unmodified.

Try it

npm i bare bare-process
./node_modules/bare/bin/bare app.js

In app code, detect the runtime when you must:

const process = (typeof Bare !== 'undefined')
  ? require('bare-process')
  : global.process

Rule we live by: never sprinkle runtime checks through app logic. One shim
module owns the differences; everything else imports the shim.

« Pear: run, stage, release, seed Hypercore: the signed append-only log »