Writing a handler#

A handler is a JavaScript file evaluated by Janus before it launches a game. Top-level statements fill in the game’s property sheet (Game.*), and functions assigned to Game.* become lifecycle callbacks.

Best done with a coding agent. Writing a handler means finding out how a game starts, where it keeps its settings and saves, and how its players find each other, then testing it with several instances. A coding agent such as Claude Code does most of that work for you. Run it in a checkout of the Janus repository and point it at AGENTS_WRITE_HANDLERS.md, which walks it through the whole process: the workflow, testing without anyone at the controllers, co-op, UI scale and common pitfalls. You then try the result with real controllers.

The complete reference is SCRIPTING.md in the Janus repository. This page covers what you need to get started and to upload.

A minimal handler#

// My Game — native Linux build (an example, not a real handler)
Game.appid = 123456;           // required: the Steam appid, on its own line
Game.name = "My Game";         // required when the game is new to the site
Game.maxPlayers = 4;
Game.isolation = "full";       // none / prefix / secondary / full
Game.exeName = "MyGame";       // executable to look for in the install dir
Game.gameArgs = "-windowed";   // prepended to the game's arguments

For real examples, read the handlers already on this site or in Janus’s handlers/ folder.

Lines Janus reads without running the script#

Janus and this site read these lines as plain text, before any code runs. Write each one on its own line, with a literal value.

Game.appid = <number>;
The Steam appid. Janus finds a game’s handler by it, and the site uses it to decide which game an upload belongs to.
Game.id = "<id>"; (instead of Game.appid)
For a game that isn’t on Steam, such as Minecraft: an id of your choice, lowercase letters, digits, - and _. Janus uses it the way it uses the appid of a Steam game, and the site matches uploads to the game by it. The site looks up the game’s cover art and logo on SteamGridDB when the game is first uploaded.
Game.name = "<name>";
The game’s name. The site uses it to create the game the first time someone uploads a handler for it.
Game.minimumJanusVersion = "<version>"; (optional)
The oldest Janus that can run the handler, e.g. "0.2". Set it when the handler uses something added to Janus recently. An older Janus refuses to load the handler, with a message to update, and when it gets handlers from this site it installs the newest version it can run instead.
Version 2 needs Janus 0.2 or newer, so this is the newest version this Janus can run
What a player with an older Janus sees.

Options#

Handlers can offer settings that appear in Janus’s GUI and on the CLI (-o key=value):

Janus.addOption("skipIntro", {
  label: "Skip intro movie",
  description: "Leave the intro movies out of the game mirror.",
  type: "bool",
  default: true,
});

Read the chosen values from ctx.options inside callbacks.

Callbacks#

All callbacks are optional. The ones you will use most:

Callback When it runs Typical use
Game.buildEnvironment(ctx, env) Before each instance starts Change environment variables
Game.play(ctx) Right before each instance is spawned Add arguments to ctx.gameArgs, edit config files with the tile size (ctx.width, ctx.height)
Game.onInstanceExit(ctx) When an instance exits Clean up, copy saves

ctx describes the instance: its number (ctx.instance), the player profile, the assigned controller, tile geometry and paths. See section 6 of SCRIPTING.md for every field.

Payloads#

A handler can ship extra files (mods, config templates, DLLs) in a payload/ folder next to it. To upload one, zip the handler’s folder so that handler.js is at the root of the zip:

my-game.zip
├── handler.js
└── payload/
    └── ...

Deploy it at runtime with Janus.deployPayload(destination).

Notes for players#

Each game on this site has notes (see Uploading and review). Janus shows them before a player installs the handler, so use them for what a player needs to know: how to start a co-op session in the game, settings to change in Steam, known problems. Keep the technical details in comments in the handler.