nx.js
Namespaces

Switch

The Switch global object contains native interfaces to interact with the Switch hardware.

Index

Classes

ClassDescription
AlbumThe Switch.Album class allows for interacting with the Switch's photo gallery, providing access to the screenshots / video recordings that the user has saved.
AlbumFileRepresents a file within a Switch.Album content store, which is either a screenshot (JPEG image) or a screen recording (MP4 movie).
ApplicationRepresents an installed application (game) on the console, or a homebrew application (.nro file).
EnvA Map-like object providing methods to interact with the environment variables of the process.
FileSystem-
FsFileThe Switch.FsFile class is a special implementation of the global File class, which interacts with the system's physical file system.
IRSensorThe IRSensor class is a Sensor subclass. When the sensor is activated, the controller's IR (infrared) camera is enabled, allowing the application to get the image data for each frame of the camera.
ProfileRepresents a user profile that exists on the system.
SaveDataRepresents a "save data store".
ServerEventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them.
SocketThe Socket class represents a TCP connection, from which you can read and write data. A socket begins in a connected state (if the socket fails to connect, an error is thrown). While in a connected state, the socket’s ReadableStream and WritableStream can be read from and written to respectively.
SocketEvent-

Interfaces

InterfaceDescription
FsFileOptionsOptions object for the Switch.file() function.
FsFileStreamOptionsOptions object for the Switch.FsFile#stream() function.
IRSensorInit-
InspectOptions-
ListenOptionsSpecifies the port number and optional IP address for creating a TCP server.
NetworkInfo-
SaveDataCreationInfoBase-
SaveDataCreationInfoWithNacp-
SaveDataFilter-
SocketAddressSpecifies the port number and optional hostname for connecting to a remove server over the network.
SocketEventInit-
SocketInfo-
SocketOptions-
Stats-
Versions-
Vibration-

Type Aliases

Variables

VariableDescription
argvArray of the arguments passed to the process. Under normal circumstances, this array contains a single entry with the absolute path to the .nro file.
entrypointString value of the entrypoint JavaScript file that was evaluated. If a main.js file is present on the application's RomFS, then that will be executed first, in which case the value will be romfs:/main.js. Otherwise, the value will be the path of the .nro file on the SD card, with the .nro extension replaced with .js.
envA Map-like object providing methods to interact with the environment variables of the process.
versionAn Object containing the versions numbers of nx.js and all supporting C libraries.

Functions

FunctionDescription
appletTypeReturns the "applet type" of the running application.
chdirChanges the current working directory to the specified path.
connectCreates a TCP connection to the specified address.
cwdReturns the current working directory as a URL string with a trailing slash.
exitSignals for the nx.js application to exit. The global "unload" event will be invoked after the event loop has stopped.
fileReturns a Switch.FsFile instance for the given path.
inspect-
listenCreates a TCP server bound to the specified port number.
mkdirSyncCreates the directory at the provided path, as well as any necessary parent directories.
networkInfo-
operationModeReturns the current "operation mode" of the device.
readDirSyncSynchronously returns an array of the file names within path.
readFileReturns a Promise which resolves to an ArrayBuffer containing the contents of the file at path.
readFileSyncSynchronously returns an ArrayBuffer containing the contents of the file at path.
removeRemoves the file or directory recursively specified by path.
removeSyncSynchronously removes the file or directory recursively specified by path.
renameSyncSynchronously renames a file or directory.
resolveDnsPerforms a DNS lookup to resolve a hostname to an array of IP addresses.
setMediaPlaybackStateSet media playback state.
statReturns a Promise which resolves to an object containing information about the file pointed to by path.
statSync-
writeFileSyncSynchronously writes the contents of data to the file at path.

On this page