> ## Documentation Index
> Fetch the complete documentation index at: https://ej3mplo.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# The SDK: window.ejg

> How a theme talks to ejGames: data, actions and events.

ejGames injects the SDK into your `index.html` before your scripts. Wait until the host sends the data:

```js theme={null}
const ejg = await window.ejg.ready();
```

From there, everything is synchronous when the data is already in memory (`ejg.library.all`, `ejg.settings`,
`ejg.profile`…) and asynchronous when you have to ask the launcher for something (`ejg.game.details()`, `ejg.explore.search()`…).

> [card] [Library](https://ej3mplo.mintlify.site/referencia/biblioteca.md)
>
> `ejg.library`: games, collections and art.

> [card] [Games](https://ej3mplo.mintlify.site/referencia/juegos.md)
>
> `ejg.game`: the page, launch, favorite, state.

> [card] [Achievements](https://ej3mplo.mintlify.site/referencia/logros.md)
>
> `ejg.game.achievements`: list, icons and rarity.

> [card] [Explore and downloads](https://ej3mplo.mintlify.site/referencia/explorar.md)
>
> `ejg.explore` and `ejg.downloads`.

> [card] [Community guides](https://ej3mplo.mintlify.site/referencia/guias.md)
>
> `ejg.guides`: each game's Steam guides.

> [card] [Cheats and maps](https://ej3mplo.mintlify.site/referencia/trucos-mapas.md)
>
> `ejg.trainer` and `ejg.maps`: FLiNG trainers and Map Genie maps.

> [card] [Profile](https://ej3mplo.mintlify.site/referencia/perfil.md)
>
> `ejg.profiles`: the local profile (name and avatar), switching and editing it.

> [card] [Homebrew](https://ej3mplo.mintlify.site/referencia/homebrew.md)
>
> Console games as a store: `createHomebrewView`, `ejg.catalogs` and `ejg.emulators`.

> [card] [Controller and keyboard](https://ej3mplo.mintlify.site/referencia/mando.md)
>
> `ejg.input` and the control hints.

> [card] [Host and window](https://ej3mplo.mintlify.site/referencia/host.md)
>
> `ejg.ui`, `ejg.sound`, `ejg.window`, `ejg.storage`.

## Events

`ejg.on(name, fn)` listens for notices from the host:

| Event | When |
| - | - |
| `settings` | the user changed a theme option in Appearance |
| `input` | the control type changed (controller, keyboard or mouse) |
| `focus-return` | a host screen closed: take the focus back |
| `visibility` | the theme stops being visible, or comes back (`{ visible }`) |

Each part also has its own `onChange` / `onState` (library, games, downloads…).

## Types

The full types are in `/_sdk/ejg.d.ts` (also inside the installation, at `sdk\ejg.d.ts`). With
`// @ts-check` and a reference to that file, your editor autocompletes the whole SDK.

> [!NOTE]
>
> Inside the iframe, `confirm()`, `alert()` and `window.open()` do not work, and there is no network and no `localStorage`. See
> [what a theme can do](https://ej3mplo.mintlify.site/referencia/limites.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.