Skip to main content

Global Variables

These JavaScript variables can be used anywhere because these variables are defined in the window scope.

Predefined global variables#

NL_OSOperating system name: Linux, Windows, or Darwin
NL_ARCHCPU architecture: x64, arm, itanium, ia32, or unknown
NL_APPIDApplication identifier
NL_APPVERSIONApplication version
NL_PORTApplication port
NL_MODEMode of the application: window, browser, cloud, or chrome
NL_VERSIONNeutralinojs framework version
NL_CVERSIONNeutralinojs client version
NL_CWDCurrent working directory
NL_PATHApplication path
NL_ARGSCommand-line arguments
NL_PIDIdentifier of the current process
NL_RESMODESource of application resources: bundle or directory
NL_EXTENABLEDReturns true if extensions are enabled
NL_COMMITFramework binary's release commit hash
NL_CCOMMITClient librar's release commit hash
NL_CMETHODSCustom method identifiers (Returns the same output that custom.getMethods returns).
NL_WSAVSTLOADEDReturns true if the initial window state was loaded from the saved configuration

You can use NL_COMMIT and NL_CCOMMIT values to identify the codebase snapshot if you use nightly releases.

Custom global variables#

You can make custom global variables too via neutralino.config.json, as shown below.

"globalVariables": {
"TEST": "Test Value"

The above custom global variable's value can be accessed with NL_TEST. You can set any data type for custom global variables. Look at the following examples.

"globalVariables": {
"TEST_1": 1,
"TEST_2": null,
"TEST_3": 3.5,
"TEST_4": [3, 5, 4, 5],
"TEST_5": {
"key": "value",
"anotherKey": 100

Avoid overriding predefined global variables.