How to Add Leaderboards to Your Game
A leaderboard is a database table and a set of design choices. Here is how to make one that keeps players competing and how much cheating you can realistically stop.

Key takeaways
- One global all-time board demotivates almost everyone. Add daily or weekly boards, friend boards and "your position" views.
- Store scores in a server database and submit them through a server function that validates them, never directly from the game.
- In a browser game, any score the client computes can be faked. Validation, limits and moderation reduce cheating; they do not remove it.
- Show players their own rank and the people just above them, so there is always a reachable next goal.
To add a leaderboard to a web game, store each score in a server database table (player, board, score, time), submit scores through a server-side function that checks them for plausibility, and display the top entries plus the player's own position. The design choices matter as much as the code: daily and weekly boards, friend rankings and "players near you" views keep far more people competing than a single all-time list. And be honest with yourself about cheating: in a browser game, a determined player can fake a score, so the goal is to make cheating hard and visible, not impossible.
Why a single global board fails
An all-time global leaderboard is exciting for the top ten players and discouraging for everyone else. Within days, the top scores are out of reach for a new player, and seeing "rank 4,812" is not a reason to try again. Better structures:
- Daily boards: reset every day, so everyone starts equal. Pair them with a daily challenge (the same seed or level for everyone) and the comparison is fair.
- Weekly boards: long enough for dedicated players to grind, short enough to stay fresh.
- Friends boards: beating a friend is more motivating than beating a stranger. Requires some way to connect players, like a shared room or a friend code.
- Around me: show the player's rank with the five players above and below. The next target is always close.
- Brackets or leagues: groups of 30 to 50 players with similar skill, with promotion and relegation each week. More work, very effective for retention.
- Per-level boards: in level-based games, best time per level gives speedrunners a playground.
The data model
Leaderboards are a small database design problem. A simple, flexible structure:
- players: id, display name, created time. Display names need moderation (more below).
- scores: id, player id, board key, score, submitted time, plus optional details for verification such as run duration, game version and a seed.
- board key: a text key that encodes the board, like "daily-2026-11-22", "weekly-2026-w47" or "level-forest-3". New boards then need no new tables.
Decide whether to keep every score or only each player's best per board. Keeping only the best keeps the table small and the queries fast; keeping all scores lets you analyze play and detect suspicious patterns. A common compromise is a best-per-player table for display and a log of recent submissions for checks. Index the scores by board key and score so "top 100 for today" is a fast query. Database basics for non-developers explains tables and queries in plain terms.
Submitting scores through the server
Never let the game write directly into the scores table. If the client can insert rows, anyone can open the browser developer tools and insert a score of 999,999,999. Instead:
- 01The game calls a server function with the score and the supporting details (duration, version, seed, maybe a compact summary of events).
- 02The function checks the player is signed in (a guest session counts) and applies rate limits, for example no more than one submission every few seconds and a few hundred per day.
- 03It checks plausibility: is the score possible in the reported time? Is the version current? Does the seed match today's challenge?
- 04If it passes, the function writes the score with server privileges. If not, it rejects it or flags it for review.
With Startbase Cloud, your project gets a managed database and edge functions, and the agent can set up the table, the access rules and the submission function for you. Database rules should let anyone read boards but block direct inserts, so the function is the only way in.
The honest truth about cheating
In a browser game, the game logic runs on the player's device, in code they can read and modify. That means any score the client computes can be faked by someone determined enough. You can raise the bar a lot, but no client-side trick makes a single-player browser leaderboard cheat-proof. Realistic defenses, from cheapest to most robust:
- Plausibility limits: maximum points per second, maximum score per level, minimum run duration. Catches lazy cheats and bugs.
- Rate limits: stop scripts from flooding submissions.
- Version checks: reject scores from old builds.
- Seeded challenges: everyone plays the same seed, so outliers stand out.
- Replays or input logs: submit the sequence of inputs and re-simulate the run on the server. If the game is deterministic, the server can recompute the true score. This is the strongest defense for single-player games, and also the most work.
- Server-authoritative play: in multiplayer games with a room server, the server runs the rules and decides the score, so the client cannot invent it. See our multiplayer guide.
- Moderation: a way to remove scores and ban players, plus a "report" button. Often the most effective tool, because people notice impossible scores quickly.
Scale your defenses to the stakes. A casual daily board among friends needs plausibility checks and moderation. A board with prizes needs replay validation or server-authoritative play, and probably a human review of winners. Row level security explained and edge functions explained cover the two backend tools behind these defenses.
Displaying the board
- Show the player first: their rank, their best, and the gap to the next rank ("42 points to beat Mira").
- Celebrate personal bests even when they are not top scores. Personal records keep most players playing.
- Reset time visible: "Daily board resets in 3h 12m" creates urgency.
- Display names: filter offensive names, limit length, and allow reporting. A leaderboard is public content.
- Number formatting: thousands separators and consistent time formats. The Startbase UI Editor supports formats like {score:number}, {time:mm:ss} and {place:ordinal} in text, so a rank reads "3rd" and a score "12,480".
A brief for a daily leaderboard
Add a daily leaderboard to my endless runner. Enable Startbase Cloud with anonymous guest sign-in and a display name chosen on first submission (3 to 16 characters, filtered for offensive words). Scores table: player id, board key like daily-YYYY-MM-DD in UTC, score, run duration in seconds, game version, submitted time; keep each player's best per board. Submit through an edge function that rejects scores over 60 points per second of run time, runs shorter than 5 seconds, old game versions and more than one submission every 10 seconds; anyone can read boards but nobody can insert directly. Results screen: the player's rank, the gap to the next player, the top 10, and a countdown to the daily reset.
Common leaderboard mistakes
- Client writes scores directly to the database.
- Only an all-time board, which becomes unreachable within a week.
- No moderation tools, so one cheater owns the board forever.
- Time zone confusion: decide whether daily boards reset in UTC or local time and say so on screen.
- Unmoderated names that turn a public board into a liability.
Leaderboards pair naturally with saved progress; our guide to saving game progress covers the account side. Published games on Startbase can also be shared to the Arcade, whose own leaderboard ranks games rather than players. Daily boards pair naturally with a daily puzzle game or an endless runner.
Frequently asked questions
How do I stop cheating on my game leaderboard?
Submit scores through a server function that checks plausibility, rate limits and game version, and add moderation tools. For high stakes, validate replays on the server or run the game logic on a server. In a browser game you can make cheating hard and visible, but not impossible.
Do leaderboards need a backend?
Yes. Scores have to live somewhere every player can read, which means a server database. A server function should handle submissions so players cannot write scores directly.
Daily or all-time leaderboard: which is better?
Daily and weekly boards keep more players competing because everyone starts fresh. Keep an all-time board for bragging rights if you like, but lead with shorter boards and the player's own position.

