Discover how Edgegap works

Discover how Edgegap works

/

Unity Server Browser

Unity Server Browser

Deploy to Edgegap

Published

Published

Published

Last reviewed for accuracy

Last reviewed for accuracy

Last reviewed for accuracy

Unity Server Browser: How to add online lobbies to your Unity multiplayer game with Edgegap

Unity Server Browser: How to add online lobbies to your Unity multiplayer game with Edgegap

This guide shows you how to add on-demand online lobbies to a Unity multiplayer game that already runs on Edgegap's dedicated game servers, with Edgegap's Server Browser: each player reserves a seat and connects to a ready server automatically, with nobody typing an address.

Once your game server is containerized, Edgegap deploys it worldwide to 615+ Edge Cloud locations (on-demand) from a simple API call and billed exclusively on usage: no entire server to rent, provision or keep running between matches. For persistent servers of reserved capacity, Edgegap offers Private Fleets. Edgegap's Matchmaking builds on top of that and is optional.

The Server Browser is a hosted service between your players and your servers. Game clients reserve seats through it (1). Each server registers itself, reports its free seats and stays visible with a heartbeat (2). Players then connect straight to the server with your netcode (3). A scaling policy starts servers so there's always capacity (4).

Server Browser call flow: game clients reserve seats through the Server Browser, dedicated servers register and send keep-alives, players connect to the server with their netcode, and a scaling policy deploys servers

This guide covers:

  1. Preparing a working Edgegap app version for your game

  2. Connecting your coding agent to Edgegap (optional)

  3. Installing Edgegap's Unity SDK

  4. Adding the integration code

  5. Adding the scripts to your scene

  6. Creating your Server Browser

  7. Deploying your server with a scaling policy

  8. Testing with two players

You can do it two ways, and mix them:

  • With a coding agent. Any AI coding assistant can write the integration code from the two prompts in step 4. Connected to the Edgegap MCP server, it can also build, push and deploy your server. You handle the clicks in Unity and the Edgegap dashboard, and playtest.

  • By hand. Every step below also works without an agent.

Here, we use Mirror's Billiards example. Any Unity netcode works the same way.

No credit card required. Free tier includes the resources to deploy a real game server.

No credit card required. Free tier includes the resources to deploy a real game server.

Step-by-Step Guide

Detailed Integration Steps

1. Before you start

  • A free Edgegap account. Verify your email. No credit card is needed to test.

  • A working Edgegap app version of your game server: a server you deployed and joined at least once. The Server Browser deploys and fills that server, so it needs a functional, containerized game server to work end to end. If you don't have one yet, use our guides:

  • Edgegap's game server build tool plugin for Unity, from those guides, to rebuild your server in step 7.

  • For the agent path: an Edgegap API token, from Dashboard → User Settings → Tokens. It is organization-wide, so treat it like a password: never put it in your project, your game client or a chat.

Git: Unity needs a Git client (2.14.0 or newer) on your PATH to install packages from a Git URL, such as the Edgegap SDK. macOS usually has one already (Xcode Command Line Tools); on Windows, install Git.

2. Connect your coding agent to Edgegap

Skip this step if you're doing everything by hand.

The Edgegap MCP server lets your agent create apps and versions, deploy servers and read logs on your account. Edgegap's agent skills don't cover the Server Browser yet, so the integration code comes from the two prompts in step 4; the skills still help with building and deploying.

Claude Code (run in your own terminal, so the token never passes through the chat):

claude mcp add --transport http edgegap https://mcp.edgegap.dev/mcp -H "Authorization: token YOUR_EDGEGAP_API_TOKEN" --scope user

Then install the skills: /plugin marketplace add edgegap/edgegap-agent-skills, then /plugin install edgegap@edgegap. Restart the session.

Cursor, VS Code and other clients that send headers: add https://mcp.edgegap.dev/mcp with the header Authorization: token YOUR_EDGEGAP_API_TOKEN, and install the skills with npx skills add edgegap/edgegap-agent-skills --skill "*".

Claude Desktop: custom connectors can't send the header, so use the local server instead (Node 18+): { "mcpServers": { "edgegap": { "command": "npx", "args": ["-y", "@edgegap/mcp"] } } }. It asks for the token on first use.

Check it works:

"List my Edgegap apps."

Your app and its version should be in the list.

3. Install Edgegap's Unity SDK

The Server Browser is part of Edgegap's Unity SDK, a separate package from the plugin that builds and deploys your server.

  1. In Unity, select Window → Package Management → Package Manager, select +, then Add package from git URL, paste https://github.com/edgegap/edgegap-unity-sdk.git and select Add.

  2. In the SDK's Samples tab, import Server Browser - Auto-Assign. It adds two scripts: a client handler that reserves a seat and hands your game the server's address, and a server handler that registers your server with the Server Browser and reports its free seats.

The SDK does almost everything. Three netcode-specific parts are left to you: the lines that connect the player to the assigned server, a small handshake that tells the server which player joined, and releasing the player's seat when they leave. Step 4 adds them.

4. Add the integration code

Two prompts for any AI coding assistant write that code for your netcode. The video below shows them on Mirror's Billiards example.

Prompt 1, audit your project (read-only):

"Read-only, no code changes. I'm integrating the Edgegap Server Browser (Auto-Assign) in my Unity project: at runtime it gives my client a reserved server's address (an FQDN) and an external port, and my server must confirm each player by a player ID. Find and tell me, with file paths and line numbers: 1) the method that starts a client connection, and the exact fields where the server address and the port are set, plus the transport in use; 2) how my netcode sends a small custom message from client to server and registers a handler for it on the server; 3) the event that fires on the client when it finishes connecting, and whether it's reset when the client starts (so I know whether to subscribe after starting the client); 4) the event that fires on the server when a player disconnects, and how it identifies the connection. Look at the NetworkManager-style class and its transport first. Confirm each against the project."

Prompt 2, write the integration:

"Using the audit, make three changes for the Edgegap Server Browser Auto-Assign integration, without subclassing or replacing my netcode's manager. 1) Create a standalone MonoBehaviour EdgegapPlayerConnector in Assets/Scripts/ (static Instance, DontDestroyOnLoad) with a small network message carrying a string playerId. On the server, register its handler in Start(): store the connection-to-playerId mapping and call ServerBrowserServerHandler.Instance.OnPlayerJoined(playerId). Expose SubscribeClientConnected(), which sends ServerBrowserClientHandler.Instance.LocalPlayerId once the client is connected, safe to call after the client starts. 2) In the sample's ServerBrowserClientHandler.cs, generate LocalPlayerId at runtime (a new GUID) and use it in the seat reservation; when seats are reserved, set the assigned FQDN as the network address, convert the external port to the type my transport expects and set it, start the client, then call SubscribeClientConnected(). 3) On the server, subscribe to the disconnect event from the audit; look up the disconnecting connection's playerId, call ServerBrowserServerHandler.Instance.OnPlayerAbandoned with the signature you read in the SDK source, and remove the entry. Guard against missing entries and a missing handler. Return the complete files."

Connect flow: read and set the address, read and set the external port, then start the client; with Mirror, the network address on the Network Manager, the port on the active PortTransport, and StartClient()Disconnect flow: detect the disconnect, look up the player, release the reservation; with Mirror, OnDisconnectedEvent and the connection ID to player ID mapping on NetworkServer, then OnPlayerAbandoned on the server handler

The audit catches netcode quirks for you. With Mirror, for example, the client-connected event is reset when the client starts, so the connector subscribes after starting the client. Without the seat release, seats leak and the server eventually reports no free seats.

Here's our video tutorial of Edgegap's Server Browser for Unity, using Mirror's Billiards example:

5. Add the scripts to your scene

In Unity, a script does nothing until it's on a game object. In your game scene, select GameObject → Create Empty three times:

  1. Edgegap Player Connector: add the connector script your assistant created.

  2. Server Browser Server Handler: add the Server Browser Server Handler component.

  3. Server Browser Client Handler: add the Server Browser Client Handler component.

Leave the handlers' fields empty for now: they come from step 6.

6. Create your Server Browser

  1. In the Edgegap dashboard, open Server Browser and create one, named for example quickstart, with the Simple Example configuration.

  2. Start it and wait until it's online. On the free tier it runs 3 hours on a shared test cluster after each start, which is fine for testing.

  3. Open its details and copy the API URL, the server token and the client token.

  4. In Unity, paste the API URL and the server token into the server handler, and the same API URL and the client token into the client handler. Swapping the tokens causes connection errors. Save the scene.

The server token can do everything on your Server Browser, so it only belongs in the server running on Edgegap, never on a player's machine. Pasting it into the component keeps this test simple; in production, set it as a variable on your app version instead, which overrides the inspector value and keeps it out of your project. The client token only reserves seats and reads status.

Two setups: with player services, the game client authenticates with your player services, which reserve the seat; without player services, the game client reserves the seat with the Server Browser directly; in both, the game server polls the Server Browser and the client connects to it

In production, many studios have players sign in to their own player services first, which reserve the seat for them.

7. Deploy your server with a scaling policy

Your server now reads the Server Browser's URL and token, so it needs a new app version: earlier builds don't have them.

  1. Build, containerize and upload your server with Edgegap's plugin, exactly as in your server guide (or Build from source to run all three at once). With your agent: "Build the Linux server, push it with a new tag and create a new app version with the same port."

  2. On your Server Browser, create a scaling policy named on-demand: Minimum Active Instances set to 1, your application and the new version, and Private Hosts empty so it deploys to Edgegap's cloud. Save it as active.

  3. Within a minute, the policy deploys your server. Its logs show it registering with the Server Browser, reporting healthy, and discoverable with free seats. Your on-demand lobby is live.

A minimum of one active instance keeps one server running at all times, ready for players. Remember it's running when you're done testing: deactivate the policy to stop it.

8. Test with two players

  1. Run two players with Unity's Multiplayer Play Mode, or the Editor plus a build.

  2. Press Play. Each player reserves a seat, gets the server's address and connects, and the server confirms each player and takes a seat.

  3. Both players land on the same cloud server, each one's actions replicated in the other's window.

Logs of two players: each reserves a seat on the same Edgegap server, then joins it

A freshly assigned server may still be starting for a moment, so for production add a connection retry: a couple of attempts, a few seconds apart.

Next Steps

Next Steps

Let players choose. Beyond auto-assignment, players can search and browse servers by region, free seats, game mode or any metadata your server reports, and pick one. Scaling policies can also keep spare servers warm for launches, or pin servers to a Private Fleet by adding its host IDs.

Prefer strict rules over player choice? See Unity Matchmaking SDK. On Unreal Engine, the Server Browser works through Betide Studios' Edgegap Integration Kit.

Stuck? Ask our team and other studios on the Edgegap Discord.

Frequently Asked Questions

Common questions about adding Edgegap's Server Browser to a Unity multiplayer game.

What is a server browser in a multiplayer game?

A list of live game servers players can join, with their free seats and settings such as region or game mode. Edgegap's Server Browser is a hosted service: servers register and report their seats, players reserve a seat and connect, and scaling policies start servers as needed.

Should I use a server browser or matchmaking?

Use a server browser when players should pick a server or drop into a running lobby, and matchmaking when your rules should decide who plays together, such as skill or team balance. Edgegap offers both, and they can work together: matchmaking starts servers and the server browser fills them.

Does Edgegap's Server Browser work with Mirror, Netcode for GameObjects and Fish-Networking?

Yes. The Server Browser doesn't depend on your netcode. Only three parts change: connecting to the assigned address and port, sending the player ID to the server, and releasing the seat when the player leaves.

What's the difference between the server token and the client token?

The server token can use every Server Browser method and belongs only in your game server, ideally as an app version variable. The client token only reserves seats and reads status, for game clients or your player services. Neither is your Edgegap API token.

How much does Edgegap's Server Browser cost?

Testing is free, on a shared cluster that runs 3 hours after each start. Servers your scaling policy deploys bill per vCPU per minute while they run, so a minimum of one active instance means one server running at all times.

Clients

Learn more from clients who integrated Edgegap

31 case studies are available from studios that moved to Edgegap from another platform.

Key reasons why they chose Edgegap

Discover the impact of Edgegap's automated game server orchestration for a flawless multiplayer experience.

Cost

Pricing

Optimize costs and performance with hybrid orchestration

Optimize costs and performance with hybrid orchestration

Optimize costs and performance with hybrid orchestration

Edge Cloud

On-Demand

$0.00115

/ vCPU

/ MINUTE

Billed by the Minute, Only on Usage

Pay only when players play. 0 active servers = $0

Deploy game servers worldwide, per instance, to all 615+ edge cloud locations. Zero commitment.

Simply add a credit card.

Edge Cloud

On-Demand

$0.00115

/ vCPU

/ MINUTE

Billed by the Minute, Only on Usage

Pay only when players play. 0 active servers = $0

Deploy game servers worldwide, per instance, to all 615+ edge cloud locations. Zero commitment.

Simply add a credit card.

Private Fleet (Bare Metal)

Reserved Capacity

$0.0282

/ vCPU

/ HOUR

Billed Monthly, Always On

$280 per host/month (12 mo rate), or $350 monthly

Optimize the cost effectiveness of your game server with egress-free hosting of Private Fleets.

Persistent, available 24/7, exclusive to your studio.

Private Fleet (Bare Metal)

Reserved Capacity

$0.0282

/ vCPU

/ HOUR

Billed Monthly, Always On

$280 per host/month (12 mo rate), or $350 monthly

Optimize the cost effectiveness of your game server with egress-free hosting of Private Fleets.

Persistent, available 24/7, exclusive to your studio.

Your bill varies per rate and usage; which can vary per game type, player count, & more.

Your bill varies per rate and usage; which can vary per game type, player count, & more.

Model your usage with our estimate calculator ->

Model your usage with our estimate calculator ->

Edgegap's features & price: detailed comparison between Edge Cloud & Private Fleets

Edgegap's features & price: detailed comparison between Edge Cloud & Private Fleets

COMPARE

Free Trial

Edge Cloud

Private Fleets

FEATURES

Analytics & Monitoring

Billing Alarms

Click to Expand

28 more rows

Unlocks

Capabilities are unlocked when a credit card is added to the account.

COMPARE

Free Trial

Edge Cloud

Private Fleets

FEATURES

Analytics & Monitoring

Billing Alarms

Click to Expand

28 more rows

Unlocks

Capabilities are unlocked when a credit card is added to the account.

COMPARE

Free Trial

Edge Cloud

Private Fleets

FEATURES

Analytics & Monitoring

Billing Alarms

Click to Expand

28 more rows

Unlocks

Capabilities are unlocked when a credit card is added to the account.