Article · Published December 3, 2026
Preventing cheating in a browser game: the server decides what has value
To prevent cheating in a browser game, start from one fact: everything that runs in the player's browser can be read and changed by the player. A gold total or a reward computed there is a suggestion, not a fact. Kalora is a tactical multiplayer game I built for the browser. This post shows what its server decides, what I left in the browser, and what that choice costs.

Anything decided in the browser can be changed by the player
A web page is a program delivered to someone else's computer. The player can open it, edit the data it saved, or send the server numbers the game never produced. Scrambling the code slows a curious person down. It does not stop a determined one.
So I do not try to make the browser trustworthy. I choose which decisions move to a server I control. In Kalora the answer is everything that has value to another player: gold, items, the marketplace, and what a fight pays out.
What the Kalora server decides: market, gold and items
Kalora is a turn-based game inspired by Dofus, drawn on an HTML canvas, with accounts and saves on Firebase. The marketplace belongs to the server. Players can read the listings, but only server code can write one. Listing an item removes it from the seller's inventory, and a purchase checks the gold, moves the item and credits the seller in one operation.
Gold has a ledger the browser cannot write. The server records the total it last accepted and refuses a jump the game could not have paid, both when saving and at the market. Each tradeable item carries a server signature tied to its owner and its exact stats, used up at sale, so a copied item cannot be sold twice.
The server replays the fight before it pays
A fight is played in the browser, where it has to feel instant. But it starts on the server, which builds the hero from the stored save, builds the monsters from its own tables and issues the seed, the number every random roll derives from. The browser records what the player did, turn by turn.
At the end, the browser sends that record. The server rebuilds the starting position, replays the player's actions with the same rules and moves the monsters itself. Only if its own replay ends in a win does it write gold, experience and loot to the save. A fight can be claimed once.
What stays in the browser because it is harmless
Not everything deserves a server. Drawing the isometric town, animating the twelve character bodies, the menus and the pace of a fight all run in the browser. A character's name, colour and gender come from the browser too: the server treats them as cosmetic, not as something to protect.
The test I apply is simple: if a player changes this value, who is affected. If it is only that player's own screen, it stays local, where it is fast. If another player could end up paying for it, the server decides.
What server authority costs, and where it stops
The combat rules now exist twice, in the page and on the server, and they must match exactly or honest players lose rewards. An automated check blocks the release if the two copies differ. The server is updated before the page, so no player meets a server that does not understand their game.
A reward now waits for the server's answer. If the connection drops, the player sees a pending reward and a retry button: a fight the server started is never paid out by the browser. The replay depends on Kalora being turn-based. I would not copy it as is into a fast action game, which has no list of turns to replay.
Never trust the client: what to decide first in any web app
The same rule applies far from games. Loyalty points, prepaid credits, stock levels, an account balance: if the page computes them and the server believes the page, someone will eventually send a better number. It is cheapest to settle before the first screen is designed.
So before building, I ask a client two things: what in this product has value, and where each of those things is decided. That list sets the server work, the budget and the tests. If your app holds credits, points, stock or money, I am happy to go through it with you.
Want something like this?
Tell me what you are building, or what you are still doing by hand, and I will tell you how I would approach it. No commitment.