Bare
Bare is the engine room of Pear: a small, fast, embeddable JavaScript runtime that runs the exact same code on desktop, mobile, and the terminal.
It sits one layer above the native C foundations and one layer below the building blocks, giving you Node-style ergonomics without the Node-sized footprint, and the freedom to embed JavaScript anywhere.
Beyond the engine
What Bare adds over raw C foundations
C and a JavaScript engine give you a way to execute code. Bare gives you a runtime: the missing pieces that make that engine productive, without dragging in a full Node.js install.
Module system
A complete CommonJS and ES module loader with Node-compatible resolution, so require('bare-fs') and import just work, including from the npm packages you already know.
Native addons
Modules load their C/C++ addons with require.addon(), calling straight into native code for crypto, codecs, and hardware access. Bare instantiates the shared library under the hood.
Threads
Spin up real OS threads with new Bare.Thread(). Each thread is its own isolated JS environment with structured data and transfer, so you can use every core.
A runtime, not just an engine
Bare wraps a modern JavaScript engine in the smallest practical runtime, then hands the rest to userland. The result is a foundation you can read end to end. It ships in places a heavyweight runtime could never go.
Starts in milliseconds with a tiny memory and disk footprint.
No global standard library to version-lock against: capabilities are opt-in modules.
The same bytes of JavaScript execute identically on every supported platform.
Userland
The bare-* standard library
Everything beyond the core lives in independent bare-* modules: fs, tcp, crypto, http1, and more. Install only what your program touches; nothing else ships with it.
bare-fs
File-system access that mirrors Node's fs API, backed by libuv for async I/O.
bare-tcp
TCP sockets exposed as familiar duplex streams.
bare-crypto
Hashing, HMAC, ciphers, and secure randomness for everyday cryptography.
bare-http1
A minimal HTTP/1 client and server you opt into only when you need it.
bare-subprocess
Spawn and manage child processes with a Node-style interface.
bare-stream · bare-events
The streams and EventEmitter primitives the rest of the ecosystem builds on.
Use Bare on its own
You don't need Pear, Hypercore, or a single peer to use Bare. It ships both as a standalone binary and as an embeddable library.
Install the CLI and run any script like you would with Node, or link the Bare library into your own C, C++, Swift, or Kotlin host and drive JavaScript from inside a larger native application.
That embeddability is exactly what lets the rest of the Pear stack run unchanged inside an Electron window, a mobile shell, or a headless server.
Install
npm i -g bare
Run
bare app.js
That embeddability is exactly what lets the rest of the Pear stack run unchanged inside an Electron window, a mobile shell, or a headless server.
Write once
One core, every platform
Write your logic once. Bare runs it byte-for-byte the same on every target, so the only thing that changes is the shell you wrap around it.
Electron & desktop
Pair Bare with Electron, starting from the hello-pear-electron template, to render a Chromium UI on Windows, macOS, and Linux while Bare workers run your application logic.
Native mobile shell
Embed Bare in React Native, Swift, or Kotlin to run shared JavaScript inside real iOS and Android apps.
Standalone binary
Run straight from the terminal or bundle into a single self-contained executable for servers and CLI tools.
In practice
Bare in a few lines
Require the bare-* modules you need, then push heavy work onto a real thread. This is the whole program: no framework, no boilerplate.
app.js
// app.js — pure JavaScript on Bare, no Node.js required
const fs = require('bare-fs')
const tcp = require('bare-tcp')
// A tiny TCP echo server, using Node-style streams.
const server = tcp.createServer((socket) => {
socket.on('data', (chunk) => socket.write(chunk))
})
server.listen(3000, () => {
console.log('listening on 3000')
})
// Offload CPU-heavy work to a real OS thread.
const thread = new Bare.Thread('./hash-worker.js', {
data: fs.readFileSync('./large.bin')
})
thread.join() // block until the worker exitshash-worker.js
// hash-worker.js — its own isolated JavaScript environment
const crypto = require('bare-crypto')
// Structured data handed in from the parent thread.
const { data } = Bare.Thread.self
const hash = crypto.createHash('sha256').update(data).digest('hex')
console.log('sha256:', hash)Frequently asked questions
- Is Bare the same as Node.js?
- No. Bare runs the same JavaScript language and a compatible module system, but it is a fraction of the size and built to be embedded. Where Node bundles a large standard library, Bare keeps the core tiny and moves everything else into independent bare-* modules you install only if you need them.
- Can I use npm packages with Bare?
- Yes. Pure-JavaScript packages generally run unmodified. Packages that reach for Node built-ins work whenever there is a matching bare-* module, and many popular libraries already ship Bare support.
- Do I have to use Pear to use Bare?
- No. Bare is a standalone, open-source runtime. The building blocks and the Pear platform are built on top of it, but you can embed Bare in your own app or run scripts from the CLI without touching the peer-to-peer stack.
- What platforms does Bare support?
- Linux, macOS, and Windows on desktop, plus Android and iOS on mobile, across x64 and arm64. The same JavaScript runs everywhere: only the native host around it changes.
- How do native addons work?
- Addons are shared libraries written in C or C++. A module loads its addon with require.addon() and calls straight into native code. Because addons build against the libjs and libuv ABIs rather than a specific engine, the same addon runs on any JavaScript engine that implements them.
- Where do I learn more?
- Full guides and the complete bare-* reference live at docs.pears.com, and the runtime source is on GitHub.
Continue through the stack
Bare is the foundation. The layers above turn it into peer-to-peer data and shippable apps.
Build on Bare
Grab the runtime, embed it anywhere, and run the same JavaScript on every platform.