Developer Documentation
OnlineGameWorlds hosts free browser games built in ANY engine that exports to WebGL or HTML5 — Unity, Godot, Construct 3, GameMaker, Phaser, PlayCanvas, Cocos, Defold, GDevelop and more. Every published game is automatically powered by XP & leveling, achievements, cloud saves, daily challenges and personalised recommendations — most features need zero extra code.
1. Supported Engines
If your engine can export a WebGL or HTML5 build that runs JavaScript in the browser, it works here. The most common choices:
| Engine | Export target | How it calls the platform |
|---|---|---|
| Unity | WebGL build target | C# ↔ JS via .jslib |
| Godot 4 | HTML5 / Web export | JavaScriptBridge |
| Construct 3 | HTML5 export | JavaScript / Browser object |
| GameMaker | HTML5 export (not GX.Games) | JavaScript extension |
| Phaser | Native HTML5/JS | Direct JavaScript |
| PlayCanvas | Native WebGL/JS | Direct JavaScript |
| Cocos Creator | Web-Mobile / Web export | Direct JavaScript |
| Defold | HTML5 export | html5.run() |
| GDevelop | Web (HTML5) export | JavaScript event |
| Three.js / plain HTML5 | Native JS | Direct JavaScript |
2. Automatic Features
Every published game gets these platform features with no extra effort from you:
| Feature | Description |
|---|---|
| XP & Leveling | Players earn XP by playing your game. Progress is tracked on their profile automatically. |
| Achievements | Platform achievements unlock based on player behaviour — no setup required. |
| Daily Challenges | Rotating daily tasks include playing games on the platform. Your game counts automatically. |
| Recommendations | Your game is recommended to players with matching interests and play history. |
| Recently Played | Players resume your game directly from their profile and the homepage. |
| Trending Badge | If your game trends, it gets a HOT badge on its card automatically. |
| Cloud Saves | Players save and load progress across devices. Optional integration — see Integration. |
| Reviews & Ratings | Players rate and review your game, shown on its game page. |
3. Integration
The platform injects a small, universal browser API into every game page. Any engine that can run JavaScript can call it — cloud saves and ads are optional add-ons on top of the automatic features.
The universal API
These globals are available on your game page:
window.OGW.saveState(slot, data) | Save a JSON string to a slot (0-9), up to 64 KB. No-ops when the player is logged out. |
window.OGW.loadState(slot) | Load a slot's JSON string (or null). Returns a Promise. |
window.ShowInterstitialAd(type, cb) | Show a full-screen interstitial ad. The game auto-pauses and resumes. |
window.ShowRewardedAd(type, cb) | Show a rewarded ad. Listen for the result event to grant the reward. |
"ogw-ad-result" event | Fires when an ad finishes: detail.result is "rewarded", "closed" or "failed". |
JavaScript-native engines
Phaser, PlayCanvas, Cocos Creator, Three.js, Kaboom and plain HTML5 run JavaScript directly — just call the API:
Cloud save
// Cloud save — works in ANY engine that runs JavaScript.
// Slots 0-9, save data is a JSON string up to 64 KB. No-ops for logged-out players.
window.OGW?.saveState(0, JSON.stringify({ score: 1234, level: 5 }));
// Load (returns a Promise)
const json = await window.OGW?.loadState(0);
if (json) {
const data = JSON.parse(json);
// …restore player progress
}Ads
// Interstitial ad — fire and forget (game auto-pauses + resumes)
window.ShowInterstitialAd?.("next", "noop");
// Rewarded ad — request it, then listen for the result event
window.addEventListener("ogw-ad-result", (e) => {
if (e.detail.result === "rewarded") {
// Player watched the full ad — grant the reward here
}
// e.detail.result can also be "closed" (skipped) or "failed"
});
window.ShowRewardedAd?.("coins", "noop");Unity (C#)
Unity reaches JavaScript through a .jslib plugin. Place the bridge in Assets/Plugins and the C# helper in Assets/Scripts.
Assets/Plugins/CloudSaveBridge.jslib
mergeInto(LibraryManager.library, {
OGW_SaveState: function(slot, dataPtr) {
var data = UTF8ToString(dataPtr);
if (window.OGW) window.OGW.saveState(slot, data);
},
OGW_LoadState: function(slot, callbackObjPtr, callbackMethodPtr) {
var obj = UTF8ToString(callbackObjPtr);
var method = UTF8ToString(callbackMethodPtr);
if (window.OGW) {
window.OGW.loadState(slot).then(function(data) {
SendMessage(obj, method, data || "");
});
}
}
});Assets/Scripts/CloudSave.cs
using System.Runtime.InteropServices;
using UnityEngine;
public class CloudSave : MonoBehaviour
{
[DllImport("__Internal")] static extern void OGW_SaveState(int slot, string data);
[DllImport("__Internal")] static extern void OGW_LoadState(int slot, string obj, string method);
public void Save(int slot = 0)
{
var payload = JsonUtility.ToJson(new SaveData { score = 1234, level = 5 });
#if UNITY_WEBGL && !UNITY_EDITOR
OGW_SaveState(slot, payload);
#else
PlayerPrefs.SetString($"save_{slot}", payload); // editor fallback
#endif
}
public void Load(int slot = 0)
{
#if UNITY_WEBGL && !UNITY_EDITOR
OGW_LoadState(slot, gameObject.name, nameof(OnLoaded));
#else
OnLoaded(PlayerPrefs.GetString($"save_{slot}", ""));
#endif
}
void OnLoaded(string json)
{
if (string.IsNullOrEmpty(json)) return;
var state = JsonUtility.FromJson<SaveData>(json);
Debug.Log($"Loaded — score: {state.score}, level: {state.level}");
}
}
[System.Serializable]
public class SaveData { public int score; public int level; }For ads, download the ready-made Unity ad scripts (interstitial + rewarded managers) and follow the setup steps — the game pauses, mutes and resumes automatically.
Godot 4
Use JavaScriptBridge from a Web (HTML5) export to call the same API and bridge the ad-result event back into GDScript:
# Godot 4 — Web (HTML5) export. Bridge to the platform with JavaScriptBridge.
var _ad_cb # keep a reference so the callback isn't garbage-collected
func _ready():
if not OS.has_feature("web"):
return
# Cloud save (fire-and-forget). saveState expects a JSON string.
var payload := JSON.stringify({ "score": 1234, "level": 5 })
JavaScriptBridge.eval("window.OGW && window.OGW.saveState(0, %s)" % JSON.stringify(payload))
# Receive ad results. A JavaScriptBridge callback takes ONE Array argument
# (the JS "arguments" converted to a Godot Array).
_ad_cb = JavaScriptBridge.create_callback(_on_ad_result)
var window = JavaScriptBridge.get_interface("window")
window.ogwAdResult = _ad_cb
JavaScriptBridge.eval("window.addEventListener('ogw-ad-result', function(e){ window.ogwAdResult(e.detail.result); })")
func show_rewarded():
JavaScriptBridge.eval("window.ShowRewardedAd && window.ShowRewardedAd('coins','noop')")
func _on_ad_result(args):
if args[0] == "rewarded":
pass # grant the rewardConstruct 3
Use a JavaScript block, or the Browser object's "Execute JavaScript" action:
// Construct 3 — in a JavaScript block, or Browser object → "Execute JavaScript".
// Cloud save
window.OGW && window.OGW.saveState(0, JSON.stringify({ score: 1234 }));
// Load
const json = window.OGW ? await window.OGW.loadState(0) : null;
// Ads
window.addEventListener("ogw-ad-result", (e) => {
if (e.detail.result === "rewarded") { /* grant reward */ }
});
window.ShowInterstitialAd && window.ShowInterstitialAd("next", "noop");
window.ShowRewardedAd && window.ShowRewardedAd("coins", "noop");Defold
From an HTML5 build, call the API with html5.run() (runs JavaScript via eval and returns the result as a string):
-- Defold — HTML5 build. Call the platform API with html5.run().
if html5 then
-- Cloud save
html5.run('window.OGW && window.OGW.saveState(0, JSON.stringify({score:1234}))')
-- Ads
html5.run("window.ShowInterstitialAd && window.ShowInterstitialAd('next','noop')")
html5.run("window.addEventListener('ogw-ad-result', function(e){ if(e.detail.result==='rewarded'){ /* reward */ } })")
html5.run("window.ShowRewardedAd && window.ShowRewardedAd('coins','noop')")
endGameMaker (HTML5)
GameMaker can't run JavaScript inline, so wrap the platform calls in a JavaScript extension (HTML5 export target only — GX.Games does not support JS extensions), then call the generated functions from GML. Use a gmcallback_ function to receive ad results:
// 1) JavaScript extension file (HTML5 target only — GX.Games does not allow JS extensions).
// Add these to a GameMaker Extension, then double-click each function in the IDE to
// create a matching GML function (same name + argument count).
function OGW_Save(slot, data) { if (window.OGW) window.OGW.saveState(slot, data); }
function OGW_ShowInterstitial(type) { if (window.ShowInterstitialAd) window.ShowInterstitialAd(type, "noop"); }
function OGW_ShowRewarded(type) { if (window.ShowRewardedAd) window.ShowRewardedAd(type, "noop"); }
// Forward ad results to a GML function named gmcallback_ogw_ad_result:
window.addEventListener("ogw-ad-result", function (e) {
if (typeof gmcallback_ogw_ad_result === "function") gmcallback_ogw_ad_result(e.detail.result);
});
// 2) GML — call the generated extension functions
OGW_Save(0, json_stringify({ score: 1234, level: 5 }));
OGW_ShowRewarded("coins");
// Receive the ad result (JavaScript calls this global GML function)
function gmcallback_ogw_ad_result(result) {
if (result == "rewarded") {
// grant the reward
}
}GDevelop
Add a JavaScript code event — you have full window access, so call the API directly:
// GDevelop — inside a "JavaScript code" event (you get `runtimeScene` + full window access).
// Cloud save
if (window.OGW) window.OGW.saveState(0, JSON.stringify({ score: 1234, level: 5 }));
// Load (async): resolve, then store into a scene variable
if (window.OGW) window.OGW.loadState(0).then(function (json) {
if (json) runtimeScene.getVariables().get("save").setString(json);
});
// Ads
window.addEventListener("ogw-ad-result", function (e) {
if (e.detail.result === "rewarded") { /* grant reward */ }
});
if (window.ShowRewardedAd) window.ShowRewardedAd("coins", "noop");Any other engine
Any engine with an HTML5/WebGL export has a way to run JavaScript. Call the exact same window.OGW / window.ShowInterstitialAd / window.ShowRewardedAd API and listen for the ogw-ad-result event — the JavaScript example at the top of this section works everywhere.
4. Technical Requirements
5. Submit Your Game
6. Support
Questions about integration or submitting your game? Get in touch and we'll respond within 24 hours.