Open Your Game
Your game is a web page, so you open it the way you’d open any file: from its folder, in your browser.
Open index.html
Open your game folder (
monogatari-v2.9.0, or the name you gave it).Double-click
index.html. Your browser opens it.On Windows, the file may show as
index, without.html: Windows hides the end of file names by default. It’s the one with your browser’s icon.If it opens in another program instead, such as your text editor, right-click it and choose Open with, then your browser. Dragging
index.htmlonto an open browser window works too.Look at the address bar. The address starts with
file://, followed by the place of the folder on your computer. That means the browser opened a file from your computer, not a page from the internet. You’ll see why it matters below.
You should see the main menu: a light gray screen with four buttons at the bottom right, Start, Load, Settings and Help.

Play the sample story
Click Start. The starter game comes with a tiny story:
- Your browser may ask whether this page can show notifications, because the sample story sends one when it starts. Answer either way: the story goes on without waiting for your answer.
- A box asks your name. Type it and press OK.
- A character called Yui greets you by your name, and asks whether you’ve read some documentation, with Yes and No buttons.
- Each answer leads to a few different lines, and then the game goes back to the main menu.

Click anywhere on the game, or press Space, to go to the next line. In the tutorial you’ll replace this story with your own.
On a tablet or a phone
Open index.html the way your editor shows pages, with its preview for example (see What you need).
The starter game is made to be played sideways. Held upright, a phone shows the main menu behind a message: Please rotate your device to play. Turn the phone sideways and the message goes away.


To make a game that plays upright, or either way, change 'Orientation' in js/options.js from 'landscape' to 'portrait' or 'any'. Aspect Ratio and Orientation explains the setting.
What works opened from a file
There are two ways to run a Monogatari game:
- Opened from the file, as you did above. The address starts with
file://. You need nothing but the browser. - Served: a web server (a program that sends the game’s files to the browser) gives the game an address that starts with
http://orhttps://. That’s what happens once your game is online, in an editor’s preview that serves the folder, and with a local web server on your own computer.
Monogatari v2 is made to be served. Opened from the file, the browser treats every file of your game as if it came from a different website, and it doesn’t let the page read them the way a website can. Pictures and text still work, so you can write and test most of your game this way, but some features stop. This table is the complete list of what we found different, in Chromium and in Firefox:
Opened from the file (file://) |
Served (http:// or https://) |
|
|---|---|---|
| The story: text, backgrounds, characters, images, choices, the player’s name | Works. | Works. |
| Videos, and fonts you add to your styles | Work. | Work. |
| Saving and loading, and the player’s settings | Work, and the browser keeps them after you close it. | Work. |
| Your changes, after you save a file | Show on the next reload. | Show on the next reload too. Over https:// and on localhost or 127.0.0.1 the game keeps a copy of its files, so a picture or sound you replace with a file of the same name shows on the second reload. See Edit, save, reload. |
Music, sound effects and voices (play music, play sound, play voice) |
Play, through a plain audio player: looping, fades, pausing, the volume sliders, saves and going back work. The audio effects of a play statement don’t apply, and the console says so once. |
Play, with their effects. |
Music on the main menu (the 'MainScreenMusic' setting) |
Plays. | Plays. |
| The picture on each save | Black, with the text box’s line in small letters. The backgrounds and characters are missing. | A picture of the game at the moment you saved. |
| Loading ahead of time (preloading) | Off: each picture is read from your disk when the game shows it. | On: the loading screen loads every file you declared in js/script.js, then shows the main menu. |
| Playing offline (the service worker) | Not available. The console says Offline play is off: browsers only run the service worker (service-worker.js) for a game served over https, or from localhost or 127.0.0.1 on your own computer, not for an index.html opened from a file. | Over https://, and on your own computer at http://localhost or http://127.0.0.1. Not over plain http:// from any other address. |
A typo in one of the game’s .js files |
A dialog titled There is a mistake in and the file, such as js/script.js. It can’t give the line: the browser keeps it for the console. | The same dialog, with the line and the browser’s own message. |
We checked each row in Chromium and Firefox, on a computer. Safari, Edge and phone browsers weren’t tested. When something goes wrong shows the typo dialogs.
A game served from a folder of a website (an address like https://example.com/after-the-bell/) works the same as one at the top of a site, offline play included.
Serve your game
To have everything in the right column, open the game from a web address. Ways that need no tools:
- Put your game online. Share your game explains how, from a browser. You can upload an unfinished version to try it served, and upload it again each time you want to check.
- Use your editor’s preview, if it serves the folder. Look at the address the preview shows. When it starts with
http://(oftenhttp://localhost:orhttp://127.0.0.1:followed by a number), the editor is serving your game folder, and the right column of the table applies there. When it starts withfile://, it’s the same as opening the file, and the left column applies. If the preview doesn’t show its address, save the game once from the quick menu: a black picture on the save slot means the left column.
The served game keeps its own saves and settings, apart from the ones of the game opened from its file: browsers keep each address’s data separately. A save you made from the file doesn’t show up in the served game, and the other way around.
Optional: a local web server with Bun
NOTE
This part is only for people with a computer (Windows, macOS or Linux) where they can install programs. You don't need it to follow the tutorial.
A local web server is a small program that serves your game folder at an address like http://localhost:5100, so your browser treats the game like a website and everything in the right column of the table works. Only your own computer can open that address. The starter game comes with one, in the file serve.ts. It runs on Bun, a free program that runs JavaScript outside of the browser.
You start it from a terminal: a window where you type commands instead of clicking. Windows has Terminal (or PowerShell), and macOS and Linux have Terminal.
Install Bun, once, following Bun’s installation page. Today it says to type this in a terminal on macOS and Linux:
curl -fsSL https://bun.com/install | bashand this in PowerShell on Windows:
powershell -c "irm bun.sh/install.ps1|iex"Close the terminal and open a new one. Type
bun --versionand press Enter: it prints a version number when Bun is installed.Go to your game folder in the terminal. Type
cdand a space, drag the game folder from your file manager onto the terminal window (its location appears aftercd), and press Enter.Start the server. Type this and press Enter:
bun run serveThe terminal answers:
Dev server running at http://localhost:5100Open http://localhost:5100 in your browser. It’s your game, served. Each time you save a file in the game folder, the page reloads by itself and shows your change, a replaced picture or sound included.
To stop the server, click the terminal and press Ctrl+C.
You don’t need to run bun install for this: the server uses nothing but Bun.
NOTE
The automatic reload came with Monogatari 2.9.0's serve.ts. In a game started from an older starter game, it doesn’t work, and the console shows an error about the Content-Security-Policy: reload the page by hand, or copy serve.ts from a new download of the starter game over yours.
Next
The project folder: what each file in the folder is for.