Peer-to-peer networking for shared 3D spaces
Peers talk directly over WebRTC. mistlib bounds each node's connection count and picks which peers to hold by 3D proximity — the nearest inside your area of interest, plus one per direction — so a crowded world never becomes a quadratic mesh.
npm install @tik-choco/mistlib
What you get
Bounded fan-out
Around 30 connections per node, configurable, however crowded the world gets.
Area of interest
You hear about the nodes near you rather than about everyone in the room.
Serverless signaling
Peers meet over Nostr relays, so there is no signaling server to operate.
Multiple rooms
Several rooms in one process, each with its own independent overlay.
Shared storage
Content-addressed blobs replicated between peers and persisted to OPFS.
Media tracks
Audio and video published over the very same WebRTC connections.
Built with mistlib
A family of browser apps that share state peer-to-peer using this library.
Browse the whole family from TC Home.
Getting started
import init, {
init_with_config, join_room, update_position, send_message,
register_event_callback, MistEvent, Delivery,
} from "@tik-choco/mistlib";
await init();
init_with_config("alice", JSON.stringify({
signaling: {
mode: "nostr",
nostr: {
relays: ["wss://relay.example.com"],
inviteSalt: "my-app", // peers sharing a salt and code find each other
inviteCode: "a-shared-secret", // pick your own, the built-ins are placeholders
},
},
aoiRange: 20.0,
}));
register_event_callback((eventType, fromId, payload, roomId) => {
if (eventType === MistEvent.PeerConnected) console.log("peer joined:", fromId);
});
join_room("lobby");
update_position(0.0, 1.5, 0.0);
send_message("", new TextEncoder().encode("hello"), Delivery.Reliable);
Call update_position as your avatar moves — it is what drives the topology
and area-of-interest calculation.
Every way to get it
| Target | How |
|---|---|
| Bundled web app | npm install @tik-choco/mistlib |
| No build step | https://cdn.jsdelivr.net/npm/@tik-choco/mistlib@0.6.2/mistlib_wasm.js |
| Latest build, this site | ./pkg/mistlib_wasm.js |
| Unity, C/C++, Python | Native library from Releases |
Pin a version. The URL on this site moves with every release. The overlay wire protocol may change between releases, and every peer in a deployment must run the same one.