nx.js
Concepts

Applications

Interacting with installed applications

The Switch.Application API is used to interact with installed applications (game titles) and/or homebrew apps (.nro files).

Instances of Switch.Application can read the app's title, author information, and other metadata. It is also possible to retrieve a JPEG format image of the title's box art (256x256 JPEG format).

Additionally, working with Save Data is preferred to be done by first retrieving the Switch.Application instance which your app is interested in working with.

Instance of current app

Use the special getter Switch.Application.self to retrieve an instance of Switch.Application which represents the currently running nx.js application.

const app = Switch.Application.self;
console.log(app.title);
Note

Using Switch.Application.self considers the various methods in which a Switch homebrew app can be launched, and loads the correct application metadata accordingly.

Iterate installed applications

The Switch.Application class can be used as an iterator for the purposes of iterating over the installed titles. This can be useful for i.e. rendering a title launcher screen or gathering information about which titles are currently installed.

let count = 0;
for (const app of Switch.Application) {
    if (app.name.includes('Super')) {
        count++;
    }
}
console.log(`You have ${count} titles which include the word "Super" in the name`);

By Title ID

If you know the specific title ID for an installed application, use the new Switch.Application(id) constructor to create an instance of the class:

const app = new Switch.Application(0x0100000000010000b);
console.log(app.title);
Caution

If the specified title is not currently installed on the system, then the accessor methods will throw an error.

By NRO file path

Pass a string or URL as a file path to a homebrew .nro file to the new Switch.Application() constructor to create and instance of the class with the:

const app = new Switch.Application('sdmc:/hbmenu.nro');
console.log(app.title);
// Logs "Homebrew Menu"

Launching an application

Use the launch() method to start up the application. This works for both installed titles as well as homebrew applications. When launching homebrew applications, additional arguments passed to the launch() method will be passed along as argv.

For example, to launch Retroarch using the snes9x core, and pass the file path of the ROM to start:

const app = new Switch.Application('sdmc:/retroarch/cores/snes9x_libretro_libnx.nro');
app.launch('sdmc:/ROMs/SNES/my-rom.sfc');

On this page