NW.js provides a robust platform for building cross-platform desktop applications using web technologies. This framework combines Node.js and Chromium to create a powerful runtime environment for desktop apps.
Getting Started with NW.js
Download the SDK from the ofifcial website (http://nwjs.io/). While some users report issues with version 0.30 archives, version 0.23 remains stable and functional.
Application Development
- Create a project directory in the NW.js executable folder
- Add these core files:
<!-- index.html -->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sample Application</title>
<script src="app.js"></script>
</head>
<body>
</body>
</html>
// app.js
document.write('Application Running');
// package.json
{
"main": "index.html",
"name": "SampleApp"
}
Running the Application
Execute the app using either:
- Command line:
nw project_folder - Drag-and-drop the folder on to nw.exe
Packaging for Distribution
- Compress all application files into a ZIP archive and rename to
app.nw - Combine with NW.js executable:
copy /b nw.exe+app.nw application.exe
- Use Enigma Virtual Box to create a standalone executable
Code Protection
NW.js SDK includes the nwjc tool for JavaScript code encryption:
nwjc app.js app.bin
This process converts JavaScript files into binary format for better protection in commercial applications.
Framework Comparison
While Electron offers similar functionality, NW.js provides better code protection features, making it more suitable for commercial applications. However, for complex system integrations with hardware devices, traditional frameworks like .NET may still be preferable.