Web
Your game folder is already a website. To release it on the web, you make a copy of it without the parts meant for you, and upload that copy to a web host: a service that keeps your files on a server and gives them an address on the internet. Players open the address in any modern browser, on a computer, phone or tablet.
None of this needs a terminal or anything installed. The last part of this page shows a command that does some of the steps for you, if you have a computer with Bun.
What a web host needs
- Static files are enough. A host that sends files as they are works. The game runs in the player’s browser and keeps its saves there, so there’s no server program or database to set up. The game’s security rules (its Content-Security-Policy) are a
<meta>tag insideindex.html, so the host needs no special settings either. index.htmlat the top of what you upload. That’s the page the host shows when someone opens your game’s address.- Relative paths. The starter game names every file relative to
index.html(./engine/core/monogatari.js,assets/icons/…), so the game also works from a sub-folder of a site, which is how itch.io serves games. Write any path you add the same way:assets/images/map.png, never/assets/images/map.png. - File names that match exactly. Most web hosts treat
Forest.pngandforest.pngas two different files, even when your computer doesn’t. Check that every name in your script matches the file, capital letters included. - HTTPS for offline play. The game plays offline through its service worker (
service-worker.js, a script the browser keeps running in the background that stores a copy of the game’s files). Browsers only run it on secure addresses, the ones that start withhttps://. Over plainhttp://the game still plays, but only online.
Give your game its name and icons
Do this once, in your game folder, so every release has it.
js/options.js:'Name'is your game’s name. The browser keeps the player’s saves under it, so don’t change it after your first release.index.html: set the<title>, the<meta name="description">and theog:tags near the top. Sites like social networks and chat apps read theog:tags to show a preview when someone shares a link to your game. Setlangon the<html>tag to your game’s language.manifest.json: setnameandshort_name. Phones and tablets show them when a player installs the game (see Mobile).service-worker.js: at the top, setNAMEto your game’s name, with no spaces or special characters. It names the game’s offline copy in the browser, together with the game’s folder on the site, so two games on one site keep separate copies even if both keep the starter’s'Monogatari'. If you changed therootofAssetsPathinjs/options.js, setASSETSto the same folder name.- Icons: replace the images in
assets/icons/andfavicon.icowith your own, at the same sizes and with the same file names.index.html,manifest.jsonandservice-worker.jsrefer to them by name.
Large images and audio files make the game slow to load, above all on a phone connection. Export images at the size the game shows them and compress audio before you add them. Asset Preloading explains how the game loads them ahead of time.
A game started before 2.9.0: update its service worker
service-worker.js belongs to your game, like js/options.js: putting a new engine in engine/ doesn’t change it. A game started from the starter game of Monogatari 2.8 or earlier has the old one, which:
- doesn’t install when the game sits in a sub-folder of a site whose top address has no page (as on itch.io), so the game never plays offline there;
- keeps showing a picture, sound or font you replaced under the same file name, until you change its
VERSION; - shows the old copy of a script or stylesheet on the first reload after you change it.
To fix all three, download the starter game again and copy its service-worker.js over your game’s. Then open it and set again what you had changed in yours: NAME at the top, and any file you added to the FILES list.
Prepare a release copy
Copy your game folder. Name the copy something like
my-game-release. You keep working in the original; the copy is what players get.Remove the debug module from the copy’s
index.html. Open it in your text editor and delete these two lines:<!-- Debug Library. Remove this file for release builds --> <script src="./engine/debug/debug.js"></script>The debug module checks your game and shows error dialogs. Those help you while you write the game and confuse players.
Turn the console messages off in the copy’s
js/main.js. Change the debug level to0:monogatari.debug.level(0);Without the debug module, the engine already stops writing every step of the story to the browser console; it still writes its errors and warnings, at the starter’s
5. At0it writes none of its own. Warnings from the browser and a few the engine writes directly still show in the console.Delete what players don’t need from the copy. The list is below. A player’s browser never asks for these files, so leaving them does no harm, but they make the upload bigger and show your project’s internals.
Open the copy’s
index.htmlin your browser and start a game, to check it still loads.
What stays in the copy:
| Keep | What it is |
|---|---|
index.html |
The page that loads the game. |
favicon.ico |
The icon in the browser tab. |
manifest.json |
The name and icons a phone or tablet uses when it installs the game. |
service-worker.js |
Offline play and faster loading. |
assets/ |
Your images, audio, video and fonts. |
js/ |
Your script, options, storage and main.js. |
style/ |
Your CSS. |
engine/core/ |
The engine. |
engine/LICENSE |
The engine’s license. |
Keep any folder of your own that the game loads, too (a data/ folder you added, say).
What you can delete: engine/debug/, engine/electron/, engine/electrobun/, engine/desktop/, types/, package.json, bun.lock, build-web.ts, serve.ts, electrobun.config.ts, jsconfig.json, jsconfig.node.json, and the node_modules/ and build/ folders if your game folder has them. They are the starter’s tools for desktop apps, the development server and code editors. Inside engine/core/, monogatari.js.map (about 5 MB) can go as well: browsers only read it when someone opens their developer tools.
Upload to itch.io
itch.io hosts browser games and serves them over HTTPS.
Make a ZIP of the copy’s contents. Select the files and folders inside the release copy, not the folder itself, and compress them into a ZIP, so
index.htmlsits at the top of the ZIP. Look for a compress or ZIP option in your file manager; on a phone or tablet, you need a file manager that can make ZIP files.Create a project on itch.io and choose HTML as its kind of project.
Upload the ZIP and choose how players see the game: embedded in the page at a size you give, or behind a button that opens it full screen.
itch.io serves each game from a sub-folder of its own site. A game started before 2.9.0 needs its service worker updated first, to play offline there. Its HTML5 guide limits what a game’s ZIP may hold: at most 1,000 files, 500 MB once unpacked, 200 MB for any one file, and file names up to 240 characters including their folders. Check the guide for the current limits and every embed option.
Upload to another web host
Any host that serves static files works. Upload the contents of your release copy so that index.html is at the top of your game’s folder on the host, then open its address in your browser and start a game. Check that the address starts with https://, for offline play.
Update a released game
Make a new release copy the same way and upload it in place of the old files. What returning players get, and when:
index.html, scripts and styles (js/,style/, the engine) are new on their next visit. The service worker asks the host for each of them every time the game loads, and uses its copy only offline.- Files under
assets/come from the copy the browser kept, so they show at once. Each time the game loads, the service worker also asks the host whether they changed, and keeps the new file if one did: an image, sound or video you replaced under the same file name reaches players by the visit after their next one, with no new name and no change toservice-worker.js. Asking costs little: for a file that didn’t change, the host answers with a few bytes instead of the file. It works with hosts that send anETagorLast-Modifiedheader with each file, as GitHub Pages and Netlify do; on a host that sends neither, changeVERSIONinservice-worker.js(for example from'0.1.1'to'0.1.2') to make every player download everything again. - When
service-worker.jschanges, a player who has the game open sees a bar at the top: “There is new content available, reload the page to get the latest version.” Clicking it closes it.

WARNING
If you add a <script> or stylesheet to index.html, add its path to the FILES list in service-worker.js too, so the game can start offline after a player’s first visit. A file in the list that’s missing on the host is skipped, and the browser console names it (The service worker couldn’t keep … for offline play).
If the update changes your script, read Keep saves working when you update your game first, so players’ saves still load.
Optional: make the release copy with Bun
If you have a computer with Bun installed (a program that runs JavaScript tools on your computer) and you’re comfortable in a terminal (the window where you type commands), the starter’s build-web.ts does steps 1, 2 and 4 for you. In a terminal, in your game folder:
bun run build:webIt writes the release into build/web/, starting from an empty folder each time so files you deleted don’t linger. It copies assets/, engine/core/, engine/LICENSE, js/, style/, favicon.ico, manifest.json and service-worker.js, and writes an index.html without the debug module’s two lines. Your own index.html keeps them. It needs nothing besides Bun: no bun install.
- It copies
js/andservice-worker.jsas they are, so set the debug level to0injs/main.jsbefore you build (and back afterwards). A game started before 2.9.0 needs its service worker updated in your game folder. - It finds the debug module’s lines by their exact text. Keep them as the starter writes them.
- A folder of your own at the top of your game folder (
data/, say) isn’t copied until you add its name to theINCLUDElist inbuild-web.ts.
To try the release on your computer, serve the build/web folder with a local server, as described in Open your game, and open the address it gives you.