Discover how Edgegap works

Discover how Edgegap works

Gemini Canvas

Deploy to Edgegap

Gemini Canvas: Take the game Gemini built online, with one dedicated server per match and Matchmaking

Published

Published

Last reviewed for accuracy

Last reviewed for accuracy

Gemini logo: Edgegap integration guide for multiplayer games built in Gemini Canvas.

Gemini Canvas can write a whole browser game from one prompt and run it in a preview next to the chat. It's a single-player game: one HTML file, you against bots, no server. This guide takes that game online. Edgegap runs a dedicated server for each match, close to its players, and stops it when the match ends. Edgegap Matchmaker is optional: it groups players who don't know each other and starts their server.

The Canvas keeps working. Solo play stays the same, and the online version runs the exact same rules on the server, copied out of Gemini's file by a script.

This guide covers:

  1. Asking Gemini Canvas for a game that can go online

  2. Splitting the rules out of the file

  3. Adding online play with a coding agent and the Edgegap MCP

  4. Building the server and creating the app version

  5. Playing online without a matchmaker

  6. Adding Edgegap Matchmaker (optional)

  7. Proving it end to end, then cleaning up

We ran this path end to end on November 20, 2026, with a game Gemini wrote from one prompt on a free account. The code is public: Bomb Tag, a Gemini Canvas game on Edgegap.

Bomb Tag gameplay, the game Gemini Canvas wrote: the player holds the bomb with 6.1 seconds left on the fuse while three bots run from it.

How the pieces fit together:

Gemini Canvas --writes--> artifact/bomb-tag.html (solo game, rules between two marker lines)

split script --copies the rules--> client/rules.js --runs on--> one Node.js server per match

Browser page --Find match--> Edgegap Matchmaker --starts--> dedicated server near the players

Browser page <== wss:// (TLS Upgrade) ==> dedicated server

What Gemini does

What your coding agent does

What you do

Writes the game as one HTML file in Canvas, with every rule in one block and a server-ready world.

Adds the server, the Find match button, the Dockerfile and the tests, and can deploy test servers through the Edgegap MCP when you say so.

Export the file, add the GitHub secrets, create the app version and the matchmaker in the dashboard, and playtest.

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.

What Gemini Canvas gives you

In Gemini, click + and pick Canvas. Canvas writes the game as one HTML file, with Code and Preview tabs, and you play it right there. Ask for changes and Gemini edits the file. Anyone you share it with plays their own copy: there's no server, so there's no match to join.

What one prompt got us

We used a free Google account with the model picker on Auto, selected Canvas, and asked for Bomb Tag: four runners in an arena, drift movement, and a bomb with a 12-second fuse that passes on touch. The holder explodes when the fuse runs out, and the last runner standing wins. What came back:

  • One file, 1,198 lines, that played in the preview: the fuse counted down on the holder and the bots ran from it.
  • A world a server can use, on the first answer. createWorld() returns no players, addPlayer() uses a free corner, setInput() accepts every player, and step() moves the bots, as asked.
  • A clean way out. Export > Download code saved the HTML file, unchanged.

No follow-up prompt was needed. The prompt asks for the server-ready world up front, which earlier chat games had to fix afterwards.

What's missing between "play it" and "play it together"

A Canvas can't host a match. Online play needs a server that decides who holds the bomb, so nobody can win by editing the page, and something that puts players who don't know each other in the same match. That's a dedicated server and a matchmaker.

The trick: keep every rule in one block

A server can't run a page, and the game has to stay one file to keep playing in Canvas. So the prompt asks Gemini to put every game rule between two exact marker lines, with nothing from the browser inside. The file still plays in Canvas, and a script copies the block out for the server. Solo and online play the same rules, with no port and no drift between them.

One server per match

Edgegap runs the server as a container and starts a fresh copy for each match, at the best available location for its players. The server stops itself when the match ends. In our test, a match cost one 0.25 vCPU server for about a minute.

Browser games need secure WebSockets

Gemini's game runs in the browser, and browsers can't open raw UDP connections. They talk to game servers over WebSockets, and a page served over https:// may only use secure WebSockets (wss://). Edgegap's TLS Upgrade gives each server a secure endpoint without you buying or renewing certificates, so the server itself stays plain ws.

Matchmaking for strangers

The Edgegap Matchmaker groups players by rules you choose and starts their server close to them. In this sample it matches 2 to 4 players. After 20 seconds in the queue, a lone player gets a match with bots in the empty seats, so nobody waits forever. You can test it for free.

Step-by-Step Guide

Detailed Integration Steps

1. Ask Gemini Canvas for a game that can go online

In a new Gemini chat, click +, pick Canvas, and send this prompt. It's the one used for Bomb Tag, word for word:

Build a small browser game as a single HTML file called "Bomb Tag" (plain Canvas 2D, no frameworks, no external libraries) and show it in Canvas so I can play it in the preview. Gameplay: 4 round runners in a square arena (800x800 units) move with WASD/arrow keys with drift (velocity + friction). One random runner holds a bomb with a 12-second fuse. Touching another runner passes the bomb to them (the new holder can't pass it back for 0.6 s). When the fuse runs out, the holder explodes and is out; the bomb goes to a random remaining runner with a fresh fuse. Last runner standing wins, then a results screen and restart. The human plays against 3 simple bots. VERY IMPORTANT architecture: put ALL game rules in one block between the exact lines /* RULES:BEGIN */ and /* RULES:END */, with NO window, document, canvas, audio, requestAnimationFrame or timers inside, and no export keyword. The world is plain data (objects, arrays, numbers, strings; no classes or Maps). The block defines createWorld() that returns a world with no players, addPlayer(world, id, name, isBot) that places each new player at its own free start spot (up to 4 players, any ids), removePlayer(world, id), setInput(world, id, {up,down,left,right}) that works for every player, step(world, dt) that moves bot players itself with botInput() and returns an array of events ({type:'pass', from, to}, {type:'boom', id} and {type:'win', winner}), and botInput(world, id) using only positions and who holds the bomb. Everything else (rendering, keyboard input, calling step() at 60 Hz) stays outside the block.

For your own game, change the gameplay sentences and keep the architecture part as it is. Here's why it's shaped this way:

Prompt detailWhy it matters online
Rules between /* RULES:BEGIN */ and /* RULES:END */, with no browser code insideThe file still plays in Canvas, and the block runs unchanged in Node.js on the server.
The world is plain dataThe server sends it to players as JSON (about 1 KB here), and the page draws it with Gemini's own render().
createWorld() with no players, a start spot per addPlayer(), setInput() for every player, bots moved inside step()The server seats its own players with its own ids and fills the empty seats with bots. Asking up front means no fix prompt.
step(world, dt) returns eventsThe server forwards passes, explosions and the win to every player, and ends the match on the win.
Bumping, chasing, running awayThe game still feels right with 50 to 100 ms of network delay. Avoid precise platforming, rhythm or instant-hit aiming.

Play it before you save it. In the Canvas preview, check that the bots move and the fuse counts down.

Get the file out. In Canvas, Export > Download code saves the HTML file. Save it unchanged as artifact/bomb-tag.html in your repo.

Done when: the file plays solo with moving bots, and it contains both marker lines.

2. Split the rules out of the file

Copy the sample's tools/split-artifact.mjs into your repo and run it once:

node tools/split-artifact.mjs artifact/bomb-tag.html --page

  • It copies the block into client/rules.js and adds an export for every function the server needs.
  • It refuses a block that uses window, document, canvas, timers or module code, and names the line, so you can ask Gemini to move it.
  • --page (first time only) writes client/index.html: Gemini's page without the block, importing the rules instead.

When you change the game later in Canvas, export the new file over the old one and run npm run split. CI runs npm run check:rules, which fails when the server's rules no longer match the file, so the server never runs old rules.

Done when: npm run check:rules reports that client/rules.js matches the file.

3. Add online play with your coding agent

Give a coding agent with the Edgegap MCP server connected this prompt. Its edgegap-chat-canvas skill holds the split script, the server templates, the matchmaker configuration and the tests used here:

Make this Gemini Canvas game online multiplayer on Edgegap. Use the Edgegap MCP and its edgegap-chat-canvas skill. Keep the solo mode, add a Find match button, 2 to 4 players per match, bots fill empty seats. Ask me before you create anything in my Edgegap account.

What gets added (all of it is in the sample, ready to copy):

FileWhat it does
server/game.jsAbout 85 lines that wrap the rules: take the four buttons from players, seat players in random order (Gemini's addPlayer() gives the bomb to the first one), run step(), which moves the bots, rank players by when they went out, send the world 20 times a second. The only server file you adapt to your game.
server/main.js, room.js, edgegap.jsConnections, match phases, bots in empty seats, and the self-stop when the match ends.
client/online.js, client/net.jsFind match through the Edgegap JS SDK, then the WebSocket to the match server, with retries while it boots.
client/index.htmlGemini's page plus about 80 lines: Find match, Local server and Cancel buttons with a status line, the server's world drawn with Gemini's render(), waiting and countdown on Gemini's own overlay. Restart still plays solo.
server/DockerfileA Node 22 image with the server and the rules.
tests/local-match.mjsTwo headless players play a full match against a local server, on every build.

The server never trusts the browser: it accepts four booleans and decides movement, passes and explosions itself. One change to Gemini's page was needed: the human's id was a constant ('p1') and the colors were keyed by the solo ids. Online, the id comes from the server, and colors follow each runner's start corner. Gemini draws names on the canvas, so there was no HTML to escape.

Done when: npm install && npm run test:local prints PASS, and two tabs on the local page see the same match.

4. Build the server and create the app version

The sample's GitHub Actions workflow builds the server on every push, checks the rules still match Gemini's file, runs the local match test, and pushes the image to the Edgegap Container Registry. You don't need Docker on your computer.

One-time setup in GitHub (Settings > Secrets and variables > Actions): a variable EDGEGAP_REGISTRY_PROJECT and two secrets, EDGEGAP_REGISTRY_USERNAME and EDGEGAP_REGISTRY_TOKEN, from the Credentials box of your Edgegap Container Registry.

Keep provenance off. By default, docker/build-push-action wraps the image in a multi-manifest index, and Edgegap then fails with "Unable to pull image from registry". Keep provenance: false and sbom: false, as the sample does.

Then create the application and its version in the Edgegap dashboard:

SettingValueWhy
vCPU0.25 (512 MB)Plenty for a 4-player Node.js match.
Port7777, protocol WS, name gameport, TLS Upgrade onPages on https can only open wss://.
Restart policyNeverA crashed match should end, not restart half-played.
Max duration30 minutesA backstop: the server normally stops itself much earlier.
EMPTY_TIMEOUT_S, FIRST_JOIN_TIMEOUT_S, RESULTS_SECONDS15, 60, 8Stop 15 s after the last player leaves, or if nobody joins within 60 s. Show results for 8 s before stopping.

To ship a new server build later, change the image tag on the version. Running matches aren't affected.

5. Play online without a matchmaker

The quickest way online, and enough for playing with friends: start one server and share its address.

  1. In Deployments, create a deployment of your version near the players, or let your coding agent deploy it through the Edgegap MCP.
  2. When it's Ready, copy the gameport address: wss://<host>:<external port>.
  3. Everyone opens your page with ?server=<that address>. Bots fill the empty seats, and the match starts 15 seconds after the first player joins.

Done when: two windows on that URL play the same match, and the deployment disappears by itself once the match is over and everyone has left.

Sharing an address works when you know who you're playing with. To put strangers in matches automatically, add a matchmaker.

6. Add Edgegap Matchmaker (optional)

This step is optional. Without a matchmaker, the game works with a shared server address, and solo play always works.

  1. In the sample's matchmaker/bomb-tag.json, set the version to your image tag and add your page's address to allowed_cors_origins.

  2. Open Matchmaker, select Create Matchmaker, upload the file, and select Create and Start. If the dashboard warns that the image "is not cached" or "not valid", continue: it can't check a private registry, and the end-to-end test in step 7 proves it works.

  3. When it's ONLINE, copy the API URL and the Auth Token into client/config.js, or a git-ignored client/config.local.js with the same shape.

The matchmaker's Auth Token is made to ship in game pages: it can only ask for matches. Never put your Edgegap API token in the page, the repo or the image.

Done when: the matchmaker shows ONLINE, and Find match on the page starts searching for players.

7. Prove it end to end, then clean up

These checks prove the whole loop works, from Find match to the server stopping itself:

  1. Serve the page with npm run client (http://localhost:8080), or publish it with the sample's GitHub Pages workflow and add that address to the CORS list.
  2. In GitHub Actions, run the Matchmaker e2e workflow. Two headless players queue, land on the same server and play a match, and the test checks that the server stopped itself.
  3. Open the page in two windows and select Find match in both within 20 seconds. Both land in the same match, with two bots, on a server near you.
  4. In the dashboard's Deployments list, check that nothing stays running after the match.

In our run, the players were matched after 13 seconds and had their server after 15, and the server stopped itself 11 seconds after the match:

e2e-1: MATCH_FOUND after 13s

e2e-1: HOST_ASSIGNED after 15s

deployment stopped itself 11s after the match

PASS

Clean up. Each match server stops itself. Stop or delete the matchmaker when you're done testing: on the free tier it stops by itself about 3 hours after each start, and Start brings it back. While it's off, Find match fails but solo play keeps working. The app version, registry images and GitHub secrets cost nothing while idle.

Frequently Asked Questions

Common questions about taking a game built in Gemini Canvas online with Edgegap’s dedicated servers and matchmaking.

Is there a working example?

Yes: Bomb Tag (netcode-sample-gemini-bomb-tag on GitHub), a 4-runner bomb-passing game Gemini Canvas wrote from one prompt. The tag before is Gemini's untouched file, and every change after it, including the optional Find match, is in the history.

Does the game still work in Gemini Canvas?

Yes. The rules stay in the file, between two marker lines, and a script copies them out for the server. Solo play against bots keeps working in Canvas, and when you change the game there, one command updates the server's copy.

Do I need a paid Gemini plan?

No. We made Bomb Tag on a free Google account with the model picker on Auto, using Canvas from the + menu.

Do I need a matchmaker?

No. Without one, start a server and share its address: everyone who opens the page with ?server= joins that match. Add the Edgegap Matchmaker when players who don't know each other should press Find match and be placed on a server near them.

What does a match cost?

In our test, one 0.25 vCPU server for about a minute. Each server stops itself when its match ends, so nothing runs while nobody plays. The free tier is enough to test: one matchmaker and one server at a time.

Which games work well online?

Games that still feel right with 50 to 100 ms of network delay: slippery movement, chasing and tagging, slow shots or turn-based play. Avoid precise platforming, rhythm games and instant-hit aiming.

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

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

/ 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.0261

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