Discover how Edgegap works

Discover how Edgegap works

/

Unity WebGL

Unity WebGL

Deploy to Edgegap

Published

Published

Published

Last reviewed for accuracy

Last reviewed for accuracy

Last reviewed for accuracy

Unity WebGL: How to host browser multiplayer games on dedicated servers, and add Matchmaking

Unity WebGL: How to host browser multiplayer games on dedicated servers, and add Matchmaking

This guide shows you how to host a multiplayer game built with Unity for the browser (WebGL) on Edgegap's dedicated game servers, then add matchmaking so players are grouped and connected to a server near them automatically, and publish it on itch.io.

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.

Browser games have one big difference from desktop games: browsers can't open UDP connections. Your game talks to its server over WebSockets, and a page served over https:// may only use secure WebSockets (wss://). Edgegap's TLS Upgrade gives every server a secure WebSocket endpoint, so you never buy or renew a certificate.

This guide covers:

  1. Preparing Unity, your netcode, your Edgegap account and a containerization tool

  2. Connecting your coding agent to Edgegap (optional)

  3. Getting your game ready for the browser and dedicated servers

  4. Building and containerizing your game server

  5. Deploying a test server and connecting to it

  6. Adding matchmaking (optional)

  7. Building the WebGL client and publishing it to itch.io

  8. Testing the full loop in two browser tabs

You can do it two ways, and mix them:

  • With a coding agent. Connect Claude Code, Cursor or another agent to the Edgegap MCP server and its agent skills. The agent edits your project, builds and containerizes the server, deploys it and writes the matchmaking code. You handle the clicks in Unity, the Edgegap dashboard and itch.io, and playtest.

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

We use Edgegap's Mirror WebGL sample, built on Mirror's Tanks example and Unity 6.3 LTS. Any Unity game with a WebSocket transport 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.

  • Unity Engine with the Linux and Web build modules installed. Edgegap recommends an LTS version.

    • Add these modules from Unity Hub: Linux Build Support (Mono), Linux Build Support (IL2CPP), Linux Dedicated Server Build Support and Web Build Support. Restart Unity after adding them.

    • The sample uses Unity 6.3 LTS. On Windows, Unity 6 may also ask for the Linux toolchain package (com.unity.toolchain.win-x86_64-linux) the first time you build for Linux.

  • A netcode with a WebSocket transport, working on localhost. We recommend Mirror and its SimpleWebTransport: its WebGL path is verified end to end with Edgegap's matchmaker. To start from our sample, download or clone the Mirror WebGL sample.

  • A containerization tool, running. We recommend Docker Desktop, installed and running while you build.

  • 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, read logs and generate matchmaker configurations on your account. The agent skills give it the tested Unity workflow, including WebGL, C# templates, the Dockerfile and the known pitfalls.

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."

An empty list is fine. An error about the token usually means the header reads token token ....

3. Get your game ready for the browser and dedicated servers

On Edgegap, no player hosts the match. A headless dedicated server owns the game, starts on its own, listens on a fixed port and stops when the match is over. For a browser game, that port speaks WebSockets.

How the connection works:

  • The server runs plain WebSockets (ws) on a fixed port, 7778 for Mirror's SimpleWebTransport. It needs no certificate: leave SSL off on the server.

  • Edgegap's TLS Upgrade adds the secure layer in front of it, with a certificate for the server's host name.

  • The client connects with wss:// to the deployment's host name (not its IP, or the certificate check fails) and its external port.

With your agent:

"Load the edgegap-unity skill and make this project a dedicated-server WebGL game: SimpleWebTransport on 7778 with SSL off on the server and wss on the client, server builds start headless on 0.0.0.0, players spawn when clients connect, and the server stops itself when the match ends. Install Edgegap SDK 3.5.5, add the server lifecycle and matchmaking client scripts with the Mirror adapter and link.xml. Then check it still works locally with one server and one client."

By hand, on Mirror:

  1. On your NetworkManager, replace KCP Transport with Simple Web Transport, port 7778. Set Headless Start Mode to Auto Start Server.

  2. Install the Edgegap SDK: in Window → Package Manager, select +, then Add package from git URL, and paste https://github.com/edgegap/edgegap-unity-sdk.git#3.5.5. Version 3.5.5 or newer is required: older versions fail the WebGL build.

  3. Keep the SDK's data classes in IL2CPP builds with a link.xml file (the sample includes one in Assets/EdgegapMatchmaking).

  4. In server builds, start the server, never a host, and spawn players when clients connect. Set Application.targetFrameRate (30 to 60) on the server, or the headless build spins a CPU core at 100%.

Other netcodes: Fish-Networking's Bayou transport works the same way (see Fish-Networking). Netcode for GameObjects can use Unity Transport with WebSockets, but that path isn't verified on Edgegap yet: test it early.

Test locally first: one Editor as the server, one as a client. Don't containerize a game that doesn't work on localhost.

4. Build and containerize your server

Edgegap runs your Linux server build inside a container. Use either option, or both.

Option A: Edgegap's automated game server build tool plugin for Unity.

  1. In Window → Package Manager, select +, then Add package from git URL, and paste https://github.com/edgegap/edgegap-unity-plugin.git. If your Mirror version already includes the plugin (Assets/Mirror/Hosting/Edgegap), skip this: installing it twice duplicates its scripts.

  2. Open Tools → Edgegap Server Hosting, sign in, and paste the token it gives you under Connect your Edgegap Account. Select Validate Token.

  3. Select Build Server, then, with Docker running, Validate and Containerize with Docker.

  4. Select Upload Image and Create App Version. In the browser, set the port: 7778, protocol WS, name gameport, and turn on TLS Upgrade. The plugin pre-fills 7770/UDP named "Game Port": change all three. Submit.

Option B: ask your agent.

"Build the Linux dedicated server, containerize it with the edgegap-unity Dockerfile for linux/amd64, push it to my Edgegap Container Registry with a new tag, then create the app and app version with port 7778, protocol WS, named gameport, with TLS Upgrade on."

The agent asks you to run docker login registry.edgegap.com yourself, with the username and token from the Container Registry page, so those credentials stay out of the chat. Make sure the app version has the registry credentials set: without them, deployments fail with "Unable to pull image from registry".

Use a new image tag for every build, never latest.

5. Deploy a test server and connect

Start one server by hand to prove the image, the port and TLS Upgrade work before adding matchmaking. Any of these works:

  • From the plugin: choose your app and version, then select Deploy to Cloud.

  • From the dashboard: open your app version in the Edgegap dashboard, select Deploy, pick a location close to you, and deploy.

  • From your agent: "Deploy my latest Edgegap version near me, wait until it's ready, check the WebSocket port answers with HTTP 101, show me the logs, and give me the host name and external port."

When the deployment is Ready, copy its Host URL and External Port. In your client's NetworkManager, set Network Address to the Host URL, set Simple Web Transport's client to use wss on that External Port, then press Play and select Client. The external port changes on every deployment, so read it each time.

If the server logs First bytes from client was not 'GET' for handshake, instead was 16-03-01, TLS Upgrade is off on the port: turn it on in a new app version.

Stop the deployment when you're done (Stop Last Deployment in the plugin, or ask your agent). The free tier runs one deployment at a time, and a forgotten test server blocks matchmaking.

6. Add matchmaking

Edgegap's matchmaker is a hosted service: players send a ticket, it groups them by your rules (match size, teams, skill, mode), deploys your server near them and returns the address to every client.

Two rules for browser games:

  • No latency rule. Browsers can't send the latency pings desktop games use. The matchmaker places the server from the players' locations instead.

  • List your origins. Put every web address that serves your game in allowed_cors_origins, or the browser blocks the matchmaker's replies. For local tests and itch.io: http://localhost:8080, https://YOUR-NAME.itch.io and https://html-classic.itch.zone.

With your agent:

"Generate an Edgegap matchmaker configuration for my WebGL app version: one team of 2 to 4 players, no latency rule, a lone player gets a server after 30 seconds, and these allowed origins: http://localhost:8080, https://YOUR-NAME.itch.io, https://html-classic.itch.zone. Save it as matchmaker-config.json."

The sample also includes a matchmaker-config.json ready to edit: set application.name and application.version to your app version.

Then, in the dashboard (this step has no API):

  1. Open Matchmaker and select Create Matchmaker.

  2. Name it, upload matchmaker-config.json, and select Create and Start.

  3. When it's ONLINE, copy the API URL and the Auth Token. The Auth Token is safe to ship in your game client: it gives no access to your Edgegap account.

Back in Unity: in the sample, activate the EdgegapMatchmaking object in the MirrorTanks scene, and set Base URL and Auth Token on TanksMatchmakingClient. Or ask your agent: "Put the matchmaker API URL and Auth Token on the matchmaking client with latency beacons off, wire my Play button to FindMatch, then rebuild and push the server and create a new app version."

When you ship a new server build, update application.version in the matchmaker configuration (Stop, Edit, Start), or matches keep deploying the old build.

7. Build the WebGL client and publish it to itch.io

  1. In Player Settings → Publishing Settings, set Compression Format to Gzip and turn on Decompression Fallback, so the build loads on hosts like itch.io.

  2. In File → Build Profiles, select Web, then Build. Or ask your agent to run the skill's WebGL client build.

  3. To test locally, serve the build folder from an allowed origin, for example python -m http.server 8080 --bind 127.0.0.1, and open http://localhost:8080.

  4. To publish, zip the build folder. On itch.io, select Upload new project, set Kind of project to HTML, upload the zip and tick This file will be played in the browser. Save, then open the page.

Your itch.io page origins must be in the matchmaker's allowed_cors_origins (step 6).

8. Test the full loop in two browser tabs

  1. Make sure no test deployment is still running.

  2. Open your game in two browser tabs or windows, locally or on itch.io. Bring each to the front before clicking: background tabs slow Unity WebGL down.

  3. Select Find Match in both. The status goes from searching to match found to host assigned, then both tabs connect to the same server.

  4. Leave the match. The sample's server stops its deployment 30 seconds after the last player leaves, or after 2 minutes if nobody joins. That self-stop is what keeps your bill at zero when nobody plays.

On the free tier, the matchmaker stops 3 hours after each start (restart it from the dashboard), deployments stop after 60 minutes, and one deployment runs at a time.

Next Steps

Next Steps

Building for desktop or mobile too? See Unity Engine and Mirror. Another browser game? See Godot Engine for Godot's web export, or Manus AI for games built with Manus.

Going live? Ask your agent to run the edgegap-launch skill's checklist: version rollouts, restart policy, maximum duration, cost control.

Stuck? Ask your agent to load edgegap-troubleshoot, or ask our team and other studios on the Edgegap Discord.

Frequently Asked Questions

Common questions about hosting a Unity WebGL multiplayer game on Edgegap's dedicated servers.

Can a Unity WebGL game connect to a dedicated server?

Yes, over WebSockets. Browsers can't open UDP connections, so use a WebSocket transport such as Mirror's SimpleWebTransport. The server runs as a Linux dedicated server build, and the browser connects to it with wss://.

Do I need an SSL certificate for my game server?

No. Turn on TLS Upgrade on the server's WebSocket port: Edgegap handles the certificate for the server's host name. Your server runs plain WebSockets, and clients connect with wss:// to the host name.

Why does my WebGL game fail to reach the matchmaker?

The browser blocks requests from origins the matchmaker doesn't allow. Add every address that serves your game, such as http://localhost:8080 and your itch.io page, to allowed_cors_origins in the matchmaker configuration.

Which netcode works best for Unity WebGL multiplayer?

Mirror with SimpleWebTransport is the path verified end to end with Edgegap's matchmaker, and Edgegap's sample uses it. Fish-Networking's Bayou transport also works. Netcode for GameObjects can use WebSockets, but test it early.

Can I host a multiplayer game on itch.io?

itch.io hosts your game's web page, not its server. Publish the WebGL build on itch.io and run the dedicated server on Edgegap; players connect from the page with wss://. Testing on Edgegap is free, with no credit card.

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.