Docs menu Getting started
Your first game in 5 minutes
Last updated 2026-11-21
This page takes an HTML5 game that already runs in a browser and gets it ready for FreeGames.gg. You add one script tag and SDK calls in four places of your game, check it in the Inspector, and upload a ZIP. You need no account until the upload. Any engine that exports to the web works: the engine guides show the same steps for Phaser, Unity and Godot.
1. Add the script (1 minute)
Put this tag in the <head> of your index.html, before your own scripts:
<script src="https://games.foony.com/sdk/v1.js"></script>It sets window.FreeGamesSdk, about 5 KB gzip with the Poki and CrazyGames adapters. Using a bundler or TypeScript? Read Install for the ES module, the npm package and the types.
2. Add calls in four places (2 minutes)
const sdk = window.FreeGamesSdk;
// 1. When your game starts: start the SDK, load, then say you're ready.
async function start() {
await sdk.init();
await loadMyGame();
sdk.loadingFinished();
}
// 2. When the player starts a level or a match.
function onLevelStart() {
sdk.gameplayStart();
}
// 3. When the level or match is over.
function onLevelOver() {
sdk.gameplayStop();
sdk.gameEnd('win'); // or 'loss', 'draw', or nothing
}
// 4. Before the next level or match (a natural break).
async function onNextLevel() {
await sdk.commercialBreak();
onLevelStart();
}
start();loadMyGame() stands for your own loading. The four call sites are your game’s own start, level start, level over and next level.
init()never fails. Every other call is safe at any time, even beforeinit()has answered.gameplayStart()andgameplayStop()frame real play. No ad shows between them, your dashboard’s play time comes from them, and so does the XP players earn in your game.commercialBreak()asks for an ad. The site’s ad rules decide if one really shows (never in the player’s first game, at least 120 seconds apart). When none shows, it finishes at once.
3. See it work (1 minute)
Open your game on your computer as you always do. Open the browser console: you see one line that starts with [FreeGamesSdk] Local mode. That means the SDK runs, with no ads and with saves in your browser, and init() answered at once.
Then serve your build folder on your computer (for example npx serve -l 8080 . inside it), open the Inspector, paste the address (http://localhost:8080/) and press Run. It runs your game in the real game frame and lists every SDK call with its time. Play one round, then start the next one: you see init, loadingFinished, gameplayStart, gameplayStop, gameEnd and commercialBreak, and a test ad at the break. The Inspector shows a test ad at every break, even after the first game, so you can test your break code. You also see activity lines while you play: that is the SDK counting real play time for XP. The Inspector warns about calls in the wrong order. A call that can’t work says why in the browser console, starting with [FreeGamesSdk].
4. ZIP and upload (1 minute)
- Select everything inside your build folder,
index.htmlincluded, and make a ZIP of it. Open the ZIP to check: you seeindex.htmlat once, not a folder. - Sign in with Foony, open the dashboard and add a new game. Drop the ZIP.
The automatic checks start at once and take about 3 minutes. Each one that fails links to its rule on the requirements page, with what we saw and how to fix it. When the checks pass, fill in the details and art, and send the game to review.
Every path in your build must be relative (game.js, not /game.js): your game runs from a folder on another domain, so a path that starts with / points at nothing.
A complete example
A whole game in one file: click the box before it runs away. Save it as index.html, open it, then try it in the Inspector.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Catch the Box</title>
<script src="https://games.foony.com/sdk/v1.js"></script>
<style>
html, body { margin: 0; height: 100%; background: #111; color: #fff; font: 20px sans-serif; }
#box { position: absolute; width: 80px; height: 80px; background: #fc0; border: 0; }
#info { padding: 12px; }
</style>
</head>
<body>
<div id="info">Loading</div>
<button id="box" hidden></button>
<script>
const sdk = window.FreeGamesSdk;
const info = document.getElementById('info');
const box = document.getElementById('box');
let score = 0;
let timer = 0;
function moveBox() {
box.style.left = `${Math.random() * (innerWidth - 80)}px`;
box.style.top = `${60 + Math.random() * (innerHeight - 140)}px`;
}
function startRound() {
score = 0;
info.textContent = 'Score: 0. Catch the box!';
box.hidden = false;
moveBox();
sdk.gameplayStart();
timer = setTimeout(endRound, 10000);
}
async function endRound() {
box.hidden = true;
sdk.gameplayStop();
sdk.gameEnd(score >= 5 ? 'win' : 'loss');
await sdk.save.set('best', String(Math.max(score, Number(await sdk.save.get('best')) || 0)));
info.textContent = `Time! Score: ${score}. Click here to play again.`;
info.onclick = async () => {
info.onclick = null;
await sdk.commercialBreak();
startRound();
};
}
box.addEventListener('click', () => {
score++;
info.textContent = `Score: ${score}`;
moveBox();
});
async function start() {
await sdk.init();
sdk.loadingFinished();
info.textContent = `Best: ${(await sdk.save.get('best')) ?? 0}. Click here to start.`;
info.onclick = () => {
info.onclick = null;
startRound();
};
}
start();
</script>
</body>
</html>What to do next
- Read the requirements once. The MUST rules are short.
- Add saves and leaderboards, and a rewarded ad the player can choose.
- Already on Poki or CrazyGames? Read Coming from Poki or Coming from CrazyGames. You swap one script tag.
- Every call is in the SDK reference.