Modding Guide for Subway Builder
Learn how to create mods for Subway Builder using the JavaScript API
Subway Builder exposes a comprehensive JavaScript API for modding. Mods can add custom cities, map tiles, UI components, game rules, and more.
What Can You Build?#
- Custom Cities - Add your own cities with custom maps, demand data, and buildings
- UI Components - Create custom panels, buttons, and overlays
- Game Modifications - Adjust train types, station behaviors, and game rules
- Visual Customization - Add custom map layers, themes, and styles
- Career Missions - Create custom challenges with win conditions
API Version#
Current version: 1.0.0
Check it in the browser console:
javascript
console.log(window.SubwayBuilderAPI.version); // "1.0.0"No Imports Needed#
Mods run as plain JavaScript via `new Function()`, so ES6 `import` statements won't work. But you don't need them! Everything you need is exposed on window.SubwayBuilderAPI:
javascript
const api = window.SubwayBuilderAPI;
// React & UI - no imports needed!
const { React, icons, components } = api.utils;
const { Button, Card, CardContent, Progress, Switch, Label, Input, Badge } = components;
const { Settings, Play, Pause, Train, MapPin } = icons; // Curated Lucide set (see UI Components guide)
const h = React.createElement; // Shorthand for building UI
// Game data - no imports needed!
const routes = api.gameState.getRoutes();
const budget = api.gameState.getBudget();
const stations = api.gameState.getStations();
// Actions - no imports needed!
api.actions.setMoney(1_000_000_000);
api.actions.setPause(true);What's Exposed#
api.utils.React- Full React libraryapi.utils.icons- Curated Lucide icons (Settings, Play, Train, etc.). See the list in UI Componentsapi.utils.components- shadcn/ui components (Button, Card, Progress, Switch, Label, Input, Badge, Tooltip, Slider)api.utils.charts- Recharts library (LineChart, BarChart, PieChart, etc.)api.utils.i18n- Translation helper for multi-language modsapi.gameState.*- All game data (routes, stations, trains, budget, ridership, metrics)api.actions.*- Game actions (setMoney, setPause, setSpeed)api.hooks.*- Lifecycle hooks (onGameInit, onDayChange, onGameEnd, etc.)
Next Steps#
- Quick Start - Test your first mod in the browser console
- First Mod - Create a proper mod with manifest
- API Reference - Explore all available APIs