Bash.tv → GitHub → itch.io

Rooms, join codes and lobbies for multiplayer games. Easy-to-read 4-letter codes, create and join, private rooms with passwords, public room lists and quick join, ready-up and start rules, host-only settings and kicking, host handover when the host leaves, rejoining a started match, a safe room view for clients, invite links, and lobby UI patterns for desktop and phones. Tested module used by t...

Download skill (.zip) Files on GitHub

Multiplayer lobbies

In a Bash kit, rooms already exist (playing-together); use this module’s rules for codes, ready-up and host handover on top.

assets/lobby.js

import { createLobbies } from "./lobby.js";
const lobbies = createLobbies({ minPlayers: 1, maxPlayers: 4 });
const { room } = lobbies.create(playerId, name, { public: false, password: null, settings: { map: "forest" } });
lobbies.join("kq7m", otherId, "Ben");            // case and spaces don't matter -> { ok } or { ok: false, error }
lobbies.setReady(otherId, true); lobbies.canStart(room.code); lobbies.start(hostId);
lobbies.leave(hostId);                            // host moves to whoever joined first; empty rooms are removed
lobbies.view(room);                               // send this to clients: no password, no ban list

Errors to show as friendly text: not_found “No room with that code”, full, started “That match already started” (offer Watch), wrong_password, kicked, not_host, not_ready.

Codes use 32 characters without 0/O and 1/I, so they’re easy to read aloud and type on a phone. 4 characters = about a million codes; use 5 for big servers.

Rules that avoid stuck lobbies

https://your.game/?room=KQ7M: on load, fill the code and join. In Bash, the space’s own link is bash.space.publicUrl when set (see playing-together for private spaces). Copy with navigator.clipboard.writeText from a click, then show “Copied”.

Lobby UI

Tested

Node tests: safe codes, case-insensitive join, ready and start rules, host-only start, full rooms, host handover to the oldest player, kick and ban, password rooms, the client view hiding secrets, quick join filling the fullest public room, started rooms refusing new players but accepting rejoin, empty rooms removed.

Pitfalls

Trusting the client’s “I’m host” flag, codes with ambiguous letters, closing the room when the host’s phone locks, rooms that never get removed, and a lobby that only works with 2+ people.