Skip to content
Docs
Rooms

Room.launch & options

Launch a room from Node with @disko-game/room, and every launch option.

A room is a Node program built on the @disko-game/room package. The package does the heavy lifting: networking, the game engine and the physics run inside it, in a fast native part that comes prebuilt. Your code just starts a room and reacts to what happens in it.

It needs Node.js 22 or later and ES modules:

sh

What launching does

Room.launch(options) does everything needed to open a room, in an order chosen so that nothing half-ready is ever visible to players:

Room.launch checks the options, opens the network port, then loads the game. Only when the game has loaded does it register the room in the directory, and then the launch resolves with the Room.

The game loads before the room is listed, so players never find a room that has no game. If any step fails, launch rejects with a DiskoError and cleans up everything it had started.

launch.js

The package never reads environment variables itself. Read your own configuration and pass it as options. The room template's main.js does this with ROOM_ID, ROOM_TOKEN, GAME, and the optional LISTEN and PUBLIC_URL. It targets the production disko services; DISKO_PROFILE=local targets a local stack, and DISKO_API_URL, DISKO_REGISTRY_URL and DISKO_PLAY_URL override single services.

main.js

The same host function runs in a test room when you copy it into a game project as server.js.

The options are grouped below. Each table lists the default and the rules a value must follow.

Identity and game

OptionDefaultRules
idrequired32 lowercase hex characters, from the Creator Portal or a test room
tokenrequiredthe room's hosting token; never logged or exposed on the Room
namerequired1–96 UTF-8 bytes, not blank, no control characters
gamerequireda release reference "ns/slug@version", or { path } for a local directory or .tgz
players{ name: "display" }the name policy: "display" or "username"

Directory and admission

OptionDefaultRules
description""at most 1024 UTF-8 bytes
publictruelisted in the directory; test rooms are never listed
gueststrueadmit players without an account
locationnull{ latitude, longitude }
passwordnull1–4096 UTF-8 bytes; read it from your own secret store
capacity641–65535 admitted players

Network

OptionDefaultRules
listen"0.0.0.0:4433"UDP bind address; see ports
publicUrlderivedthe WebTransport URL players connect to
transportPath"/room"
certificateautomatic{ certificatePem, privateKeyPem } as PEM strings

Operations

OptionDefaultRules
endpointsproduction hosts{ api?, registry?, play? } base URLs
cacheDirOS cache dir + /disko-game/releasesrelease cache, keyed by digest
leaseSeconds305–300
logging{ filter: "disko=info", format: "pretty" }engine logs go to stderr; format is "pretty" or "json"
limitsserver defaultsqueue and rate overrides, such as eventQueue (4096)

Unknown option keys reject with invalid_option, so typos are never ignored.

The Room object

The Room that launch resolves to is your handle on the running room.

Its properties always show the current state: id, url, link (the play.disko.ooo/?room=<id> link you share), state, game, players, and the directory settings name, description, public, guests, location and capacity.

To change settings while the room runs, use setName, setDescription, setPublic, setGuests and setLocation. Directory changes show up for players within about 200 ms.

Every method returns a Promise that settles once the change has been applied, and changes to one room apply in the order you make them. A setter checks its value like the matching launch option and rejects with invalid_option. After close(), every method rejects with closed.

The room also has permissions, actions, options and bans; see Permissions & moderation. Every member is in the @disko-game/room reference.

Errors

Rejections are DiskoError with a code: invalid_option, invalid_state, invalid_message, invalid_event, unauthorized, game_not_found, game_removed, game_invalid, game_build_failed, game_start_failed, registry_unavailable, listen_failed, certificate_invalid and closed. game_invalid and game_build_failed carry problems, each linking to its error page. The code is stable; the message is not. See DiskoErrorCode for what each code means.