Share current JSON values between Node.js, browsers and other KinopioHub SDKs. Node.js creates and selects a LAN node automatically; browsers connect as clients.
Requires Node.js 24+. Run the commands below from this source checkout.
A Hub owns one immutable namespace: new KinopioHub("demo"), then hub.var("battery"). Omit the namespace for a new isolated UUID. Use the same explicit namespace to share values; namespaces do not provide access control. It uses wire protocol 4.
Run from this repository:
npm install
node examples/watch.mjs
# In another terminal:
node examples/basic.mjsInstall this matching source checkout with npm install /path/to/KinopioHub.JS.
Variables live in SDK memory. A running instance retains state while offline; when the last copy exits, its state disappears.
Installation, API, configuration and test instructions are in the Wiki.
Issues and feedback: GitHub Issues · License
Stable references also expose independent messaging operations. Publishing an event does not update the current value. Once connected:
const battery = hub.var('battery');
console.log(battery.get(0));
const subscription = await battery.sub(value => console.log(value));
const responder = await battery.handle(() => battery.get(0));
await battery.pub(80);
console.log(await battery.req());
await hub.drain({ timeout: 5000 });pub/sub/req forward to publish/subscribe/request; an omitted request body sends JSON null. get(fallback) uses the fallback only for unknown or deleted values. watchValue retains state watch timing and cancellation. Events are never buffered offline or replayed. Node and browsers support wildcards, queue groups, Headers and bounded requestMany. Browsers conservatively reject drain while any handler is running; owners should stop producing work and await handlers before draining. See the JavaScript API reference for options.