Menu
P2P apps
Signaling, a relay, TURN and an offline mailbox for browser and device apps that talk peer to peer, at your own hostnames.
A P2P app (a "room" on the main site) gives an app whose users talk to each other directly — a chat, a shared whiteboard, a game — the services it needs to find each other and connect: signaling, a relay, TURN for when a direct connection is impossible, and an optional offline mailbox for peers who are not online.
Create an app#
$ weird p2p create chat --origin https://chat.example.roThe name is a DNS label (a-z, 0-9 and inner hyphens); the app answers at once on <name>.<p2p domain>. Its addresses (signaling, TURN, relay, mailbox) are in weird p2p get chat.
--originlists the web origins allowed to connect (repeat it;*.example.rowildcards work; at most 20). Without any, every origin may connect.--mailboxturns the offline mailbox on.--setting key=numbersets one of the app's limits; values above a limit's ceiling are held at the ceiling.
An app bills by the hour while it exists, plus the traffic it relays and the mailbox it keeps:
Credit charge: see the credit charges (contract recurring.p2p-app-hourly per_hour)
One app kept for a full year.
Credit charge: see the credit charges (contract p2p.relay-traffic per_mb_relayed)
Per MB passed through the relay.
Change it#
$ weird p2p update chat --add-origin https://beta.example.ro$ weird p2p update chat --origin https://chat.example.ro$ weird p2p update chat --clear-origins$ weird p2p update chat --relay off --mailbox on
--add-origin, --remove-origin, --setting and --unset change only what they name. weird p2p delete chat deletes the app and stops its billing; its name is free again once it is torn down.
Your own hostnames#
$ weird p2p domains attach chat rtc.example.ro$ weird p2p domains verify chat rtc.example.ro
Point the name at the app as you are told (a CNAME, or an A record at a zone's apex); it is set up once the record has resolved for two minutes. An app has at most 5 hostnames, and a hostname belongs to one app. A wildcard hostname (--wildcard) needs its zone hosted with weird.
Credentials for your app's clients#
$ weird p2p turn chat$ weird p2p mailbox token chat --room room-1
TURN credentials and mailbox tokens are short-lived and printed once; give them to the client. They cannot be withdrawn: they expire, so keep their lifetime short (--ttl, in seconds; a mailbox token lasts at most 24 hours).
The offline mailbox#
The mailbox keeps payloads per room for peers that come online later:
$ weird p2p mailbox send chat room-1 note.bin$ weird p2p mailbox receive chat room-1
Messages are kept for 24 hours by default; each app sets its own period with its mailbox_ttl_hours setting, up to the ceiling the platform sets:
$ weird p2p update chat --setting mailbox_ttl_hours=72The node stores exactly the bytes sent: encrypt payloads in your app before depositing them. What the mailbox keeps is billed per MB and hour, and what it serves per MB.
Credit charge: see the credit charges (contract recurring.p2p-app-hourly per_mb_hour_cached)
Per MB kept in the mailbox, for a full year.
Credit charge: see the credit charges (contract p2p.mailbox-traffic per_mb_served_mailbox)
Per MB served from the mailbox.
Build against the protocol#
$ weird p2p protocolprints the signaling, relay, TURN and mailbox protocol your app is written against.
Reference#
- Commands: weird p2p
- API: p2p operations
- MCP tools: p2p toolset