Skip to content

node-mgbaHeadless Game Boy & GBA emulator for Node.js

Step frames, press buttons, read memory and capture the screen in Game Boy, Game Boy Color and GBA games, all from TypeScript. Powered by mGBA's libmgba core, built for AI agents, automation and research.

A pixel-art screen with a small robot in a sunset landscape and a dialog box reading emu.controls.press('A')

Install ​

sh
pnpm add node-mgba
sh
npm install node-mgba
sh
yarn add node-mgba

Requires Node.js 20 or newer on x64 Linux or Windows. Bring your own ROMs.

A game in a few lines ​

ts
import { Mgba } from 'node-mgba';

// Load a ROM (.gb, .gbc or .gba)
const emu = await Mgba.load('./game.gb');

// Advance a second of game time, then press A
await emu.controls.tick(60);
await emu.controls.press('A');

// Read memory and grab the screen
const playerX = await emu.memory.read8(0xd362);
const png = await emu.screen.toPng();

await emu.close();

Continue with the guide →

Where it came from ​

node-mgba started as the emulator layer for Gemini Plays Pokémon, the 24/7 Twitch stream where Gemini plays Pokémon on its own. It's the same code the stream runs on, packaged so you can build your own game-playing agents. Read The Making of Gemini Plays Pokémon, or watch the agent think in the web viewer.