The NW.js object allows access to features specific to the NW.js exporter, such as reading and writing files to the local disk drive.
Note that the AJAX object can read files from the application folder (but not write files) when exporting to NW.js. This may allow you to implement file reading in a cross-platform manner. Also note the AJAX object reads files asynchronously, whereas the NW.js object conducts all operations synchronously.
NW.js is essentially a standalone version of the Google Chrome web browser, but while looking like an ordinary desktop app (so there are no browser tabs, address bar, back/forward buttons etc). Exporting using NW.js allows your project to run as a standalone desktop app on Windows, Mac and Linux, and does not require any particular other browser to be installed.
Note NW.js was formerly known as node-webkit.
Since NW.js is based on the Google Chrome browser, usually previewing in Chrome will run it identically to when exported with NW.js. However the features of the NW.js plugin (such as file access) do not work in the Google Chrome web browser. In order to test these features in preview mode, it is possible to choose NW.js for the Preview browser project property. This allows you to test your game with the features of this plugin working.
Note that previewing with NW.js runs directly from its install directory. As a consequence, the AppFolder expression will return the install path. If this poses a problem for you, use the following workaround: have a global string variable; if 'Is in preview' is true hard-code it to some development folder somewhere else, otherwise set it to NWjs.AppFolder. Then use the global variable instead of the AppFolder expression.
Never hard-code paths (such as using an action to write to a fixed file path like "C:\MyGame\MyFile.txt"). This unfriendly to users, and is often perceived as unprofessional, untidy, or filling the user's system with junk. Not only that but in many cases it simply will not work, since not all users have permission to read or write to folders outside of their user directory.
It is tempting to solve this by writing files to the application's folder. However this also may not work; on many versions of Windows, the Program Files folder requires administrator permission to write to, although you can read from it.
The solution is to write to the user's folder, which you almost certainly have write permission for. This is provided by the UserFolder expression. The correct way to determine a file path in the user's folder is like this:
NWjs.UserFolder & "myfile.txt"
If you only need to read files, and don't need to write them, you can safely use the application folder (NWjs.AppFolder) instead.
The NW.js object has the ability to read and write text files on disk. To support all possible languages, it always reads and writes with the UTF-8 encoding. To ensure the plugin reads your own text files correctly, ensure they are encoded as UTF-8.