Ramesh Inampudi

Games

Building a Serverless Multiplayer Game Room with WebRTC

By Ramesh Inampudi · 2026-11-13 · 5 min read

Playing a quick game with a friend online is more awkward than it should be. Someone has to install an app, someone else has to create an account, and the game usually depends on a server that somebody has to host and pay for. For a small side project, that last part matters most: a server turns a weekend game into something I have to keep running.

I built Ramesh's Game Room to avoid all three problems. It is a small collection of browser games you can play with a friend by opening a link. This article covers what is in it, how the peer-to-peer play works, and the choices that kept it simple.

Why I built it

The goal was narrow: open a link, play a game, no installs, no accounts. I also wanted no backend server to run or pay for. That constraint shaped everything else. If there is no server holding game state, the two players' browsers have to talk to each other, which is what WebRTC is for.

The project is plain JavaScript, CSS and HTML. There is no build step to explain and no framework to keep up to date. Any static file host can serve it, and it is deployed on both GitHub Pages and Vercel.

What it does

The Game Room currently has these games live:

A Monopoly / Indian Business game is planned but not built yet.

Two features go beyond the games themselves:

How it works

Every game is static HTML, JavaScript and CSS. Online multiplayer uses WebRTC through PeerJS, so the two browsers connect directly to each other. The flow is:

  1. Player A opens a game and clicks Create Game. That generates a short room code and a shareable link.
  2. Player A sends the code or link to Player B by text, WhatsApp or anything else.
  3. Player B clicks Join Game and enters the code. The two browsers form a direct peer-to-peer connection and the match starts.

PeerJS's free public broker is used only to help the two browsers find each other. Once they are connected, game moves travel directly between the two devices.

Host and guests for bigger tables

Poker and Snakes & Ladders extend the same idea beyond one-on-one play. One player is the host, and the others join as guests. Poker supports up to 6 seats and Snakes & Ladders up to 4. The host runs the game and broadcasts state to every guest.

For poker, that broadcast is personalized per viewer, so nobody sees anyone else's hole cards until showdown. This is a reusable pattern: when one peer is the authority, it can decide what each other peer is allowed to know and send each of them only that. Solo practice against computer-controlled opponents is available too.

Project layout

Each game lives in its own folder under games/<game-name>/ with its own index.html, either self-contained or with its own CSS and JS files. The root index.html has a card for each game. Adding a game means creating a folder and adding a card.

Running it locally

Any static file server works. For example:

python3 -m http.server 8000

Then open http://localhost:8000. For GitHub Pages, I use Settings, then Pages, then Deploy from branch, with main and / (root).

What I learned

A broker is not a server. The public PeerJS broker only introduces the two browsers. Game traffic never goes through it, so I have no game backend to host. The trade-off is that I depend on a free public service for the introduction step, which is the part I would look at first if connections ever became a problem.

A room code is a good interface. A short code and a link work over any messaging app, which is how people actually invite each other. Nobody needs to sign in or be in a friends list.

Make the host the authority. With a host and several guests, one device runs the rules and everyone else receives state. This avoids conflicting game states between peers. It also made hidden information in poker straightforward, because the host can send each player a different view.

Keep data local when you can. The daily challenge streaks and results live in localStorage. That means no accounts and no database, but also that results belong to one browser. Clearing it clears them, and they do not follow you to another device.

Static files make deployment easy. Because there is nothing to compile or host, I can serve the same files from two places. Making each game a PWA then gives offline access to pages that have been opened once, without extra infrastructure.

Try it

You can play it here: https://games.iramesh.com. Open a game, click Create Game, and send the link to a friend. The daily challenge in 2048 and Memory Match needs no one else at all.

Conclusion

The Game Room started from one constraint: no installs, no accounts and no server to pay for. WebRTC with PeerJS made that possible by letting players connect directly, with a host peer acting as the referee for larger tables. If you have a small multiplayer idea, consider whether it really needs a backend before you build one. Monopoly / Indian Business is the next game on my list.

Live: https://games.iramesh.com