Built for Macondo ร Hack Club Where bros (and everyone else) code together in real time โ no accounts, no servers, no nonsense.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ { BroCode } JavaScript main.js โ Connected โ [Alice] [Bob] โ
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ CONNECTION โ โฉ Undo โช Redo โฅ Indent // Comment A+ Aโ โ
โ cs-BR0C0D3 โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Name: Alice โ 1 // โฆ Welcome to BroCode ๐ฏ โ
โ Partner IDโฆ โ 2 โ
โ [Connect] โ 3 function greet(name) { โ
โ [Disconnect] โ 4 return `What's good, ${name}!` โ Alice ๐ขโ
โ โ 5 } โ
โ CHAT โ 6 โ
โ Alice: Yo bro โ 7 const squad = ["Alice", "Bob"]; โ
โ Bob: On it ๐ โ 8 squad.forEach(bro => { Bob ๐ด โ
โ Alice: ๐ค โ 9 console.log(greet(bro)); โโโโโโโโ โ
โ Bob: ๐ฏ โ 10 }); โ
โ [Type hereโฆ] โ 11 โ
โ โ 12 // No server. No login. Just share an ID ๐ค โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ JavaScript โข 12 lines โข Latency: 14ms โ
โโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- Open in two browser tabs or two devices
- Copy your Peer ID โ paste it into your partner's field โ hit Connect
- Type anywhere โ the other screen updates in real time
| Feature | What It Does |
|---|---|
| ๐ข Real-time code sync | Every keystroke broadcasts as a compact delta to your partner โ no lag, no full-page snapshots |
| ๐ฑ๏ธ Dual live cursors | Your cursor is teal, your partner's is coral โ both visible with floating name labels |
| ๐ต Remote selection highlight | See exactly what text your partner has selected |
| ๐ฌ Built-in bro chat | Side-panel chat so you never have to switch tabs |
| ๐ 5 languages | JavaScript, Python, HTML, CSS, C++ with full syntax highlighting |
| ๐ One-click ID share | Copy your 9-char Peer ID and send it via WhatsApp, Discord, anything |
| โฉ๏ธ Undo / Redo | Full per-user edit history |
| ๐ฌ Comment toggle | Ctrl+/ or the toolbar button |
| ๐ Font size controls | A+ / Aโ for any screen size |
| ๐ Copy code | Grab the whole editor content in one click |
| โก Latency meter | Live ping/pong latency displayed in the status bar |
| ๐ Auto-resync | If edits ever drift, a full snapshot resync fires automatically |
| ๐ก Zero backend | 100% peer-to-peer WebRTC โ the PeerJS relay only handles the initial handshake |
| Layer | Technology | Why |
|---|---|---|
| Networking | PeerJS v1.5.4 | WebRTC wrapper โ direct P2P data channel |
| Signalling | 0.peerjs.com (free) |
Exchanges connection metadata; never sees your code |
| NAT traversal | Google STUN servers | Lets peers behind routers find each other |
| Editor | CodeMirror 5 | Professional in-browser editor with syntax highlighting |
| Fonts | JetBrains Mono + Space Grotesk | Mono for code, humanist sans for UI |
| Hosting | GitHub Pages | Free, instant, zero-config static hosting |
| Build tools | None | Single HTML file โ no npm, no webpack, no Node.js |
You type a character
โ
โผ
CodeMirror fires 'change' event
โ {from: {line:3,ch:4}, to: {line:3,ch:4}, text: ["x"]}
โ
โผ
PeerJS DataConnection.send(delta)
โ
WebRTC data channel โ direct P2P, ~5โ50ms latency
โ
โผ
Partner receives delta
โ
โผ
editor.replaceRange(text, from, to, '+remote')
(applying flag prevents echo loop)
โ
โผ
Cursor position broadcast follows immediately
| Type | Direction | Payload | Purpose |
|---|---|---|---|
delta |
both โ | {from, to, text} |
Incremental keystroke change |
full-sync |
either โ | {code, lang} |
Full snapshot on connect or resync |
cursor |
both โ | {line, ch, label} |
Remote cursor position |
selection |
both โ | {anchor, head} |
Remote text selection highlight |
chat |
both โ | {text, name} |
Chat message |
meta |
both โ | {name} |
User display name announcement |
lang |
both โ | {lang} |
Language change sync |
ping / pong |
both โ | {ts} |
Round-trip latency measurement |
request-sync |
either โ | โ | Trigger a full resync after drift |
brocode/
โโโ index.html โ Entire application (HTML + CSS + JS in one file)
โโโ README.md โ This file
โโโ SETUP_GUIDE.md โ Step-by-step GitHub Pages deployment guide
The entire app lives in index.html. No dependencies to install, no build step, no config files.
# No installation needed โ just open the file
open index.html # macOS
start index.html # Windows
xdg-open index.html # LinuxOpen a second browser tab with the same file and connect.
See SETUP_GUIDE.md for the full walkthrough, or:
# 1. Clone / create your repo
git clone https://github.com/YOUR_USERNAME/brocode.git
cd brocode
# 2. Push
git add index.html README.md SETUP_GUIDE.md
git commit -m "feat: BroCode real-time collaborative editor for Macondo"
git push origin main
# 3. Enable GitHub Pages
# Repo โ Settings โ Pages โ Deploy from main โ / (root) โ Save
# 4. Your live URL:
# https://YOUR_USERNAME.github.io/brocode/- Open the URL in your browser
- Your Peer ID appears automatically (e.g.
cs-BR0C0D3) - Enter your Display Name in the sidebar
- Click ๐ Share ID โ copy it โ send to your partner via Discord, WhatsApp, etc.
- Open the same URL
- Paste your partner's Peer ID into "Partner's Peer ID"
- Enter your Display Name
- Click Connect โ green "Connected โ" means you're live
- Type normally โ every keystroke syncs to your partner instantly
- Your teal cursor and their coral cursor are both visible at all times
- Their selected text appears as a coral-tinted highlight on your screen
- Use the Chat panel to talk without switching apps
- Change the language from the dropdown โ it syncs to your partner too
| Shortcut | Action |
|---|---|
Ctrl+/ or Cmd+/ |
Toggle line comment |
Tab |
Insert 2 spaces |
Ctrl+Z |
Undo |
Ctrl+Shift+I |
Copy your Peer ID to clipboard |
Escape |
Close the share modal |
Browser A Browser B
โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
CodeMirror Editor CodeMirror Editor
โ change events โ change events
โผ โผ
Delta encoder โโโโ WebRTC RTCDataChannel โโโโโบ Delta decoder
Delta decoder โโโโโ direct P2P, no relay โโโโโโ Delta encoder
โ โ
Remote cursor render Remote cursor render
Remote selection render Remote selection render
โ โ
Chat panel โโโโโโโ chat messages โโโโโโโบ Chat panel
โโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
โ
Signalling only
(0.peerjs.com)
Used ONCE during
connection setup โ
never sees your code
| Browser | Support |
|---|---|
| Chrome / Edge 90+ | โ Full |
| Firefox 85+ | โ Full |
| Safari 15+ | โ Full |
| Opera 76+ | โ Full |
| Mobile Chrome / Safari | โ Full |
| Internet Explorer | โ WebRTC not supported |
| Problem | Solution |
|---|---|
peer-unavailable error |
Peer ID was mistyped โ always use copy-paste |
| Can't connect on public/school WiFi | Some networks block WebRTC UDP. Switch to a mobile hotspot |
| Changes stopped syncing | Click Disconnect โ reconnect. A full sync fires on every new connection |
| Partner's cursor not visible | Normal until they move โ just type or click to trigger a broadcast |
peer-destroyed error |
Reload the page. A fresh Peer ID is generated on each load |
| GitHub Pages shows 404 | Confirm the file is named exactly index.html (lowercase) in the repo root |
Macondo is Hack Club's annual hackathon celebrating creative, technically interesting builds.
"It's Google Docs for code, but with zero backend. Share a 9-character ID with your bro โ they paste it, click Connect, and you're both in the same editor in real time. Two cursors, built-in chat, any browser, one HTML file."
- Zero backend โ BroCode is a static file. The PeerJS relay only touches the initial ICE handshake, never your code
- Delta sync โ only
{from, to, text}diffs are transmitted (not full snapshots), making it fast even on 3G - Automatic resync โ if deltas ever drift, a full snapshot fallback restores consistency immediately
- Real WebRTC โ actual
RTCDataChannelwith ordered, reliable delivery; not a simulation or polling hack - Pixel-accurate cursors โ CodeMirror bookmark widgets inject DOM nodes directly into the editor's text flow
MIT โ free to use, fork, remix, and ship to hackathons.
| Dependency | License |
|---|---|
| PeerJS | MIT |
| CodeMirror 5 | MIT |
| JetBrains Mono | OFL-1.1 |
| Space Grotesk | OFL-1.1 |
{ BroCode } โ because the best code is written with your crew. ๐ค Made with โค๏ธ for Macondo ร Hack Club.