# Steam lobbies and multiplayer in Godot

To put a Godot game online through Steam: create a lobby with Steam.createLobby(type, max_members) and wait for lobby_created; let friends join through the overlay with Steam.activateGameOverlayInviteDialog(lobby_id) and handle join_requested; find public lobbies with Steam.requestLobbyList() and lobby_match_list; then run Godot's high-level multiplayer over Steam with GodotSteam's SteamMultiplayerPeer: create_host(0) on the lobby owner, create_client(owner_steam_id, 0) on everyone else, and multiplayer.set_multiplayer_peer(peer). Players need no port forwarding, connections use Steam IDs rather than IP addresses, and setting server_relay routes client traffic through the host.

Source: https://flockbay.com/blog/godot-steam-multiplayer/ · Updated 2026-10-18

## Steam solves the hardest part of indie multiplayer: finding each other

Most indie multiplayer games are played with friends, and the hard part is rarely the netcode. It is getting two people into the same match: sharing an IP address, opening a port, explaining a server browser. Steam already knows who your friends are, lets them click Join Game on your profile, and connects players by Steam ID through its own network, so nobody opens a port. GodotSteam exposes all of it to GDScript.

The obvious approach is to write a server browser first. For a friends-first game, the better order is the reverse: lobbies, overlay invites and Join Game first, because that is how most players will ever connect, and a public lobby list later, if the game needs strangers at all.

## Three layers, three jobs

A Steam multiplayer game in Godot has three layers, and keeping them separate keeps the code simple:

| Layer | What it does | In code |
| --- | --- | --- |
| Lobby (Steam) | Matchmaking: who is playing together, invites, Join Game, lobby data | Steam.createLobby, joinLobby, setLobbyData, requestLobbyList |
| Transport (GodotSteam) | Carries packets between players over Steam by Steam ID | SteamMultiplayerPeer |
| Replication (Godot) | Spawns, syncs and calls across peers | MultiplayerSpawner, MultiplayerSynchronizer, @rpc |

The game code above the transport is standard Godot; swapping the peer is what makes it a Steam game.

## Create and join a lobby

A lobby is Steam's meeting room: up to 250 members, and private, friends-only, public or invisible. Create one on the host, wait for the callback, and open the invite dialog:

Sources: [GodotSteam: Lobbies](https://godotsteam.com/tutorials/lobbies/), [Steamworks: Steam Matchmaking & Lobbies](https://partner.steamgames.com/doc/features/multiplayer/matchmaking).

```
func host() -> void:
	Steam.lobby_created.connect(_on_lobby_created)
	Steam.createLobby(Steam.LOBBY_TYPE_FRIENDS_ONLY, 4)

func _on_lobby_created(result: int, lobby_id: int) -> void:
	if result == Steam.RESULT_OK:
		Steam.setLobbyData(lobby_id, 'name', 'My lobby')
		Steam.activateGameOverlayInviteDialog(lobby_id)

func _ready() -> void:
	Steam.join_requested.connect(func(lobby_id: int, _friend: int) -> void: Steam.joinLobby(lobby_id))
	Steam.lobby_joined.connect(_on_lobby_joined)
```

## Join Game, invites and lists

- **Invites**: activateGameOverlayInviteDialog() opens Steam's friend picker. It may not work when the game was not launched from Steam.

- **Join Game** from a friend's profile fires join_requested if the game is running; if it is not, Steam launches it with +connect_lobby and the lobby ID on the command line, so read the command-line arguments at startup too.

- **Public lobbies**: add filters, call requestLobbyList(), and read the results in lobby_match_list (up to 50).

- **Closing a lobby**: setLobbyJoinable(false) once the match starts.

- **Lobby data**: key-value strings on the lobby for the map, mode and version, which other players can filter by.

Sources: [GodotSteam: Lobbies](https://godotsteam.com/tutorials/lobbies/), [Steamworks: Steam Overlay](https://partner.steamgames.com/doc/features/overlay).

## Carrying the game: SteamMultiplayerPeer

Once everyone is in the lobby, GodotSteam's SteamMultiplayerPeer lets Godot's normal high-level multiplayer run over Steam. GodotSteam's tutorial creates the host peer when the lobby is created and each client's peer after it joins, using the lobby owner's Steam ID instead of an IP address:

Sources: [GodotSteam: MultiplayerPeer](https://godotsteam.com/tutorials/multiplayer_peer/).

```
var peer := SteamMultiplayerPeer.new()

# On the lobby owner, once lobby_created fires:
func start_host() -> void:
	peer.server_relay = true
	peer.create_host(0)
	multiplayer.set_multiplayer_peer(peer)

# On everyone else, once lobby_joined succeeds:
func start_client(lobby_id: int) -> void:
	var owner_id: int = Steam.getLobbyOwner(lobby_id)
	peer.server_relay = true
	peer.create_client(owner_id, 0)
	multiplayer.set_multiplayer_peer(peer)
```

## Caveats from GodotSteam

- **server_relay = true** routes client traffic through the host rather than client to client, which means fewer connections per client and lets clients join after the host has loaded the spawner scene.

- **The host is a player**, peer ID 1; dedicated servers are not what this setup covers, and GodotSteam's server builds do not yet include the multiplayer peer.

- **Set authority in _enter_tree()**, not _ready(), because spawn synchronization does not allow authority changes during _ready().

- **Host migration and disconnects** are yours to handle: decide what happens when the host leaves.

GodotSteam describes its tutorial code as simplified and not production-ready, which is a fair warning: treat it as the skeleton of your netcode, not the netcode.

Sources: [GodotSteam: MultiplayerPeer](https://godotsteam.com/tutorials/multiplayer_peer/).

## Steam networking or ENet?

Godot's built-in ENetMultiplayerPeer connects by IP address and port, which is fine on a LAN, for dedicated servers you host, and for players willing to forward ports. SteamMultiplayerPeer connects by Steam ID, needs no ports opened, and pairs naturally with lobbies and invites, but it only works for players on Steam. Many games keep both behind the same high-level API: ENet for a dedicated-server or LAN mode, Steam for friends playing together. Because both are MultiplayerPeers, the switch is one line where the peer is assigned; the spawners, synchronizers and RPCs above it do not change.

## Lobby data, versions and matchmaking hygiene

Put the game version in the lobby data, and refuse to join a lobby from a different version: a patch that changes a synced property otherwise produces desyncs that look like netcode bugs. Store the mode and map there too, so a lobby list can filter on them. Leave the lobby cleanly when a match ends, with Steam.leaveLobby(), so stale lobbies do not pile up in searches, and mark a lobby unjoinable once the match starts.

## Rich presence: let friends see the match

Friends join games they can see. Steam's rich presence shows a line of status under a player's name in the friends list, such as "In lobby (2/4)", and groups friends who are playing together. In GodotSteam it is Steam.setRichPresence(key, value), with a few keys Valve defines:

- **steam_display**: the status line, which must be a localization token such as #InLobby, uploaded in Steamworks under Rich Presence Localization before it shows.

- **steam_player_group** and **steam_player_group_size**: put players in the same match in one group in the friends list, with its size.

- **connect**: a command-line string Steam passes to a friend who presses Join Game, for games that connect without a lobby.

Update it when the player enters a lobby, starts a match and returns to the menu, and clear it with Steam.clearRichPresence() on quit.

Valve's Steamworks documentation: [Enhanced Rich Presence](https://partner.steamgames.com/doc/features/enhancedrichpresence), [ISteamFriends Interface](https://partner.steamgames.com/doc/api/ISteamFriends).

## Testing it

1. **Use your own App ID** as soon as you can. Under app 480, your lobbies mix with every other developer's Spacewar test lobbies; filter by a lobby data key of your own until then.

2. **Use two machines and two Steam accounts.** One Steam client signs in one account at a time, so a second PC, a laptop or a friend is the practical setup.

3. **Launch from Steam** for invites and Join Game; the overlay may not work for a game started from the editor.

4. **Test Join Game with the game closed**, so the +connect_lobby path runs.

5. **Test the host leaving** mid-match, and a client joining late.

Valve's Steamworks documentation: [Steam Overlay](https://partner.steamgames.com/doc/features/overlay).

## Where Flockbay fits

In Flockbay, you can test multiplayer with a friend through join-code rooms while you build, free on every account and with no Steam setup. For the shipped game on Steam, Flockbay's AI writes GodotSteam into it as an ordinary autoload you own: the lobby, the overlay invite, Join Game and SteamMultiplayerPeer, standing down while a Flockbay room is the peer. Nothing of Flockbay's ships in your game, and online play in the released game runs on Steam under your own App ID.

## Questions

### Do players need to port forward for Steam multiplayer in Godot?

No. SteamMultiplayerPeer connects players by Steam ID through Steam's networking, not by IP address.

### How many players can a Steam lobby hold?

Up to 250, according to GodotSteam's lobby documentation.

### Can I test Steam multiplayer on one computer?

Not easily: one Steam client signs in one account at a time. Use two machines with two Steam accounts, and launch from Steam so invites and Join Game work.

### Does SteamMultiplayerPeer work with MultiplayerSpawner and RPCs?

Yes. It is a MultiplayerPeer, so Godot's high-level multiplayer (MultiplayerSpawner, MultiplayerSynchronizer, @rpc) runs over it unchanged once it is set with multiplayer.set_multiplayer_peer().

Download Flockbay free: Flockbay builds Godot games for free, and writes GodotSteam multiplayer into them. https://flockbay.com/free-ai-game-maker/

Related: [The indie game publishing guide](/blog/indie-game-publishing-guide/), [GodotSteam setup](/blog/godotsteam/), [Steam achievements in Godot](/blog/godot-steam-achievements/), [Port a Godot game to Steam](/port-godot-game-to-steam/)
