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 (256 x 256 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 blob

After reading a homebrew .nro file into memory, it is possible to use the new Switch.Application(nroBlob) constructor to create and instance of the class:

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

The app.launch() function is currently not implemented for instances of Switch.Application which were created from a homebrew .nro file. This may change in the future - see #125.

On this page