Class Application

Represents an installed application (game) on the console, or a homebrew application (.nro file).

Can be used as an iterator to retrieve the list of installed applications.

Example

for (const app of Switch.Application) {
console.log(app.name);
}

Hierarchy

  • Application

Constructors

  • Creates an Application instance from the ID of an installed application.

    Parameters

    • id: bigint

      The ID of the installed application.

    Returns Application

    Example

    const app = new Switch.Application(0x100bc0018138000n);
    console.log(app.name);
  • Creates an Application instance from an ArrayBuffer containing the contents of a .nro homebrew application.

    Parameters

    Returns Application

    Example

    const nro = await Switch.readFile('sdmc:/hbmenu.nro');
    const app = Switch.Application.fromNro(nro);
    console.log(app.name);

Properties

author: string

The author or publisher of the application.

The raw JPEG data for the cover art of the application. Can be decoded with the Image class.

id: bigint

The 64-bit unique identifier of the application (PresenceGroupId).

The raw NACP data of the application. Use the @tootallnate/nacp module to parse this data.

name: string

The name of the application.

version: string

The version of the application.

Accessors

  • get self(): Application
  • An Application instance representing the currently running application.

    Returns Application

Methods

  • Creates the Cache storage for this Application for the specified save index ID.

    Parameters

    • index: number = 0

      The save index ID. Defaults to 0.

    Returns void

  • Creates the Save Data for this Application for the provided user profile.

    Parameters

    Returns void

    Example

    const profile = Switch.currentProfile({ required: true });
    app.createSaveData(profile);
  • Launches the application.

    Returns never

    Note

    This only works for installed applications (not homebrew apps).

  • Mounts the Cache storage for this application such that filesystem operations may be used.

    Parameters

    • index: number = 0

      The save index ID. Defaults to 0.

    • Optional name: string

      The name of the device mount for filesystem paths. If not provided, a random name is generated.

    Returns SaveData

  • Mounts the save data for this application such that filesystem operations may be used.

    Parameters

    • profile: Profile

      The Profile which the save data belongs to.

    • Optional name: string

      The name of the device mount for filesystem paths. If not provided, a random name is generated.

    Returns SaveData

    Example

    const profile = Switch.currentProfile({ required: true });
    const saveData = app.mountSaveData(profile);

    // Use the filesystem functions to do operations on the save mount
    console.log(Switch.readDirSync(saveData.url));

    // Make sure to use `saveData.commit()` after any write operations
    const saveStateUrl = new URL('state', saveData.url)
    Switch.writeFileSync(saveStateUrl, 'your app stateā€¦');
    saveData.commit();

Generated using TypeDoc