Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Demonstrates adding a system tray icon with a menu in NW.js.
// package.json
{
"name": "tray-example",
"main": "index.html",
"window": { "title": "Tray Example", "width": 400, "height": 300 }
}
// index.html
<!DOCTYPE html>
<html>
<body>
<h1>Tray Example</h1>
<script>
const nw = require('nw.gui');
const tray = new nw.Tray({ title: 'Tray', icon: 'icon.png' });
const menu = new nw.Menu();
menu.append(new nw.MenuItem({ label: 'Show', click: () => nw.Window.get().show() }));
menu.append(new nw.MenuItem({ label: 'Exit', click: () => nw.App.quit() }));
tray.menu = menu;
</script>
</body>
</html>NW.js (previously known as Node-Webkit) is an open-source framework for building desktop applications using web technologies (HTML, CSS, JavaScript) with full access to Node.js APIs.
Origin & Creator
Developed by Intel’s Open Source Technology Center in 2011 (originally as Node-Webkit) to enable web developers to build desktop applications easily.
Industrial Note
NW.js is popular for desktop apps that need a web-like interface, rapid prototyping, or access to Node.js modules in a desktop environment.