nw.js
Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
Top Related Projects
:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
Build smaller, faster, and more secure desktop applications with a web frontend.
Portable and lightweight cross-platform desktop application development framework
A library for building cross-platform native desktop applications with Node.js and CSS 🚀. React NodeGui : https://react.nodegui.org and Vue NodeGui: https://vue.nodegui.org
:zap: Native, high-performance, cross-platform desktop apps - built with Reason!
Rust bindings for the FLTK GUI library.
Quick Overview
NW.js (previously known as node-webkit) is an app runtime based on Chromium and Node.js. It allows developers to create desktop applications using web technologies like HTML, CSS, and JavaScript. NW.js enables direct access to Node.js modules and APIs from the DOM, providing a powerful platform for building cross-platform desktop applications.
Pros
- Cross-platform development: Build applications for Windows, macOS, and Linux using a single codebase
- Access to Node.js and Chromium APIs: Combine web technologies with native desktop capabilities
- Large ecosystem: Leverage the vast array of npm packages and web libraries
- Easy to learn: Familiar web technologies make it accessible for web developers
Cons
- Large application size: The bundled runtime can result in larger application sizes compared to native apps
- Performance overhead: May not be as performant as native applications for resource-intensive tasks
- Limited mobile support: Primarily focused on desktop platforms, with limited options for mobile development
- Potential security concerns: Exposing Node.js APIs to the DOM can introduce security risks if not properly managed
Getting Started
- Install NW.js globally:
npm install -g nw
- Create a new project directory and navigate to it:
mkdir my-nw-app && cd my-nw-app
- Create a
package.json
file with the following content:
{
"name": "my-nw-app",
"main": "index.html"
}
- Create an
index.html
file:
<!DOCTYPE html>
<html>
<head>
<title>My NW.js App</title>
</head>
<body>
<h1>Hello, NW.js!</h1>
<script>
const os = require('os');
document.write('Running on ' + os.platform());
</script>
</body>
</html>
- Run the application:
nw .
This will launch your NW.js application, displaying "Hello, NW.js!" and the current operating system platform.
Competitor Comparisons
:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
Pros of Electron
- More active development and larger community support
- Better integration with native OS features and APIs
- Extensive documentation and learning resources
Cons of Electron
- Larger application size due to bundled Chromium
- Higher memory usage compared to NW.js
- Slightly steeper learning curve for beginners
Code Comparison
NW.js:
nw.Window.open('index.html', {}, function(win) {
win.maximize();
});
Electron:
const { BrowserWindow } = require('electron');
let win = new BrowserWindow({ width: 800, height: 600 });
win.loadFile('index.html');
win.maximize();
Both frameworks allow developers to create desktop applications using web technologies. NW.js provides a more straightforward approach for packaging web apps, while Electron offers greater flexibility and control over the application lifecycle.
Electron has gained more popularity in recent years, with notable applications like Visual Studio Code and Atom being built on it. However, NW.js remains a viable option, especially for simpler projects or those requiring a smaller footprint.
Ultimately, the choice between the two depends on specific project requirements, development team expertise, and desired application features.
Build smaller, faster, and more secure desktop applications with a web frontend.
Pros of Tauri
- Smaller application size due to using native OS webviews
- Better security with a Rust-based backend
- More modern tech stack (Rust, WebView2) compared to NW.js (Node.js, Chromium)
Cons of Tauri
- Less mature ecosystem and community compared to NW.js
- Limited access to native APIs compared to NW.js's full Node.js integration
- Steeper learning curve for developers not familiar with Rust
Code Comparison
NW.js:
const gui = require('nw.gui');
const win = gui.Window.get();
win.maximize();
Tauri:
#[tauri::command]
fn maximize_window(window: tauri::Window) {
window.maximize().unwrap();
}
The code snippets demonstrate window manipulation in both frameworks. NW.js uses JavaScript with Node.js integration, while Tauri uses Rust for backend operations and exposes commands to the frontend.
Tauri's approach offers better performance and security but requires more setup. NW.js provides easier access to Node.js APIs but results in larger application sizes.
Both frameworks allow developers to create desktop applications using web technologies, but they differ in their underlying architecture and design philosophy. The choice between them depends on specific project requirements, team expertise, and performance considerations.
Portable and lightweight cross-platform desktop application development framework
Pros of Neutralinojs
- Lightweight: Smaller application size and lower memory footprint
- Cross-platform: Supports Windows, macOS, and Linux with a single codebase
- Native API access: Provides direct access to system-level features
Cons of Neutralinojs
- Limited ecosystem: Fewer third-party extensions and plugins compared to NW.js
- Less mature: Newer project with potentially fewer resources and community support
- Limited browser features: May lack some advanced web technologies available in NW.js
Code Comparison
NW.js:
const gui = require('nw.gui');
const win = gui.Window.get();
win.maximize();
Neutralinojs:
Neutralino.window.maximize();
Both frameworks allow easy window manipulation, but Neutralinojs offers a more streamlined API. NW.js requires importing the nw.gui
module and creating a window object, while Neutralinojs provides direct access to window functions through its global Neutralino
object.
Neutralinojs aims for simplicity and lightweight applications, making it suitable for projects where minimal resource usage is crucial. NW.js, being more established, offers a wider range of features and better integration with Node.js, making it ideal for complex applications requiring extensive web technologies and npm packages.
A library for building cross-platform native desktop applications with Node.js and CSS 🚀. React NodeGui : https://react.nodegui.org and Vue NodeGui: https://vue.nodegui.org
Pros of NodeGUI
- Smaller application size and lower memory usage
- Native look and feel with better performance
- Cross-platform development using Qt framework
Cons of NodeGUI
- Less mature ecosystem and community support
- Limited web technologies integration
- Steeper learning curve for developers familiar with web technologies
Code Comparison
NodeGUI:
const { QMainWindow, QWidget, QLabel, FlexLayout } = require("@nodegui/nodegui");
const win = new QMainWindow();
const centralWidget = new QWidget();
const label = new QLabel();
label.setText("Hello World");
const rootLayout = new FlexLayout();
centralWidget.setLayout(rootLayout);
rootLayout.addWidget(label);
win.setCentralWidget(centralWidget);
win.show();
NW.js:
<!DOCTYPE html>
<html>
<head>
<title>NW.js App</title>
</head>
<body>
<h1>Hello World</h1>
<script>
console.log(nw.App.manifest);
</script>
</body>
</html>
NodeGUI focuses on native UI components using Qt, resulting in a more desktop-like experience and smaller application size. NW.js, on the other hand, leverages web technologies, making it easier for web developers to create desktop applications but at the cost of larger file sizes and potentially higher resource usage. NodeGUI offers better performance and a native look, while NW.js provides a more familiar development environment for web developers and easier integration with web technologies.
:zap: Native, high-performance, cross-platform desktop apps - built with Reason!
Pros of Revery
- Native performance with OCaml and Reason
- Cross-platform UI development with a single codebase
- Lightweight and fast startup times
Cons of Revery
- Smaller community and ecosystem compared to NW.js
- Steeper learning curve for developers unfamiliar with OCaml/Reason
- Limited documentation and resources
Code Comparison
Revery (React-like syntax):
let app = () =>
<View>
<Text text="Hello, World!" />
<Button title="Click me" onClick={() => print_endline("Clicked!")} />
</View>;
App.start(app);
NW.js (HTML and JavaScript):
<!DOCTYPE html>
<html>
<body>
<h1>Hello, World!</h1>
<button onclick="console.log('Clicked!')">Click me</button>
<script>
nw.Window.open('index.html', {}, function(win) {});
</script>
</body>
</html>
Key Differences
- Revery uses a React-like component model, while NW.js relies on traditional web technologies
- Revery compiles to native code, offering better performance than NW.js's interpreted JavaScript
- NW.js has a larger ecosystem and more extensive documentation
- Revery provides a more consistent cross-platform look and feel
- NW.js allows direct use of Node.js APIs, while Revery requires bindings for native functionality
Rust bindings for the FLTK GUI library.
Pros of fltk-rs
- Lightweight and fast, with minimal dependencies
- Native look and feel on multiple platforms
- Rust-based, offering memory safety and performance benefits
Cons of fltk-rs
- Limited to desktop applications, unlike NW.js's cross-platform capabilities
- Smaller ecosystem and community compared to NW.js
- Less suitable for web developers transitioning to desktop development
Code Comparison
fltk-rs:
use fltk::{app, button::Button, frame::Frame, prelude::*, window::Window};
fn main() {
let app = app::App::default();
let mut wind = Window::new(100, 100, 400, 300, "Hello from rust");
let mut frame = Frame::new(0, 0, 400, 200, "");
let mut but = Button::new(160, 210, 80, 40, "Click me!");
wind.end();
wind.show();
but.set_callback(move |_| frame.set_label("Hello World!"));
app.run().unwrap();
}
NW.js:
const gui = require('nw.gui');
const win = gui.Window.get();
win.on('loaded', function() {
document.getElementById('myButton').addEventListener('click', function() {
document.getElementById('myFrame').textContent = 'Hello World!';
});
});
Both examples create a window with a button that, when clicked, updates text on the screen. fltk-rs uses Rust and FLTK bindings, while NW.js leverages web technologies within a native application context.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
node-webkit is renamed NW.js
Official site: https://nwjs.io
Introduction
NW.js is an app runtime based on Chromium
and node.js
. You can
write native apps in HTML and JavaScript with NW.js. It also lets you
call Node.js modules directly from the DOM and enables a new way of writing
native applications with all Web technologies.
It was created in the Intel Open Source Technology Center.
Building a Cross-platform Desktop App with NW.js
Creating Desktop Applications With node-webkit
WebApp to DesktopApp with node-webkit (slides)
Essay on the history and internals of the project
Features
- Apps written in modern HTML5, CSS3, JS and WebGL.
- Complete support for Node.js APIs and all its third party modules.
- Good performance: Node and WebKit run in the same thread: Function calls are made straightforward; objects are in the same heap and can just reference each other.
- Easy to package and distribute apps.
- Available on Linux, Mac OS X and Windows.
Downloads
-
v0.91.0: (Aug 21, 2024, based off of Node.js v22.2.0, Chromium 128.0.6613.36) : release notes
NOTE You might want the SDK build. Please read the release notes. -
Mac 10.10+: 64bit
-
Use Legacy build for Win XP and early OSX.
-
latest nightly build from git tip: https://dl.nwjs.io/live-build/
-
Previous versions; See the mapping file for the version info in previous releases.
Demos and real apps
You may also be interested in our demos repository and the List of apps and companies using nw.js.
Quick Start
Create index.html
:
<!DOCTYPE html>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
We are using node.js <script>document.write(process.version)</script>.
</body>
</html>
Create package.json
:
{
"name": "nw-demo",
"version": "0.0.1",
"main": "index.html"
}
Run:
$ /path/to/nw . (suppose the current directory contains 'package.json')
Note: on Windows, you can drag the folder containing package.json
to nw.exe
to open it.
Note: on OSX, the executable binary is in a hidden directory within the .app file. To run node-webkit on OSX, type:
/path/to/nwjs.app/Contents/MacOS/nwjs .
(suppose the current directory contains 'package.json')
Documents
Official documentation: http://docs.nwjs.io/
For more information on how to write/package/run apps, see:
And our Wiki for much more.
Community
We use the google group as our mailing list (use English only). Subscribe via nwjs-general+subscribe@googlegroups.com.
NOTE: Links to the old google group (e.g. https://groups.google.com/forum/#!msg/node-webkit/doRWZ07LgWQ/4fheV8FF8zsJ
) that are no longer working can be fixed by replacing node-webkit
with nwjs-general
(e.g https://groups.google.com/forum/#!msg/nwjs-general/doRWZ07LgWQ/4fheV8FF8zsJ
).
Issues are being tracked here on GitHub.
The source code for NW.js and the daily development spans multiple repositories in this organization. This repository is for issue tracking, landing page, and part of the source code.
Verifying Binaries
Starting from 0.32.0 the stable and nightly download directories contain a SHASUMS256.txt file that lists the SHA checksums for each file available for download, as well as the checksums for the files inside the download package.
The SHASUMS256.txt can be downloaded using curl
.
$ curl -O https://dl.nwjs.io/vx.y.z/SHASUMS256.txt
To check that a downloaded file matches the checksum, run
it through sha256sum
with a command such as:
$ grep nwjs-vx.y.z.tar.gz SHASUMS256.txt | sha256sum -c -
The stable releases (but not Nightlies) also have the GPG detached
signature of SHASUMS256.txt available as SHASUMS256.txt.asc. You can use gpg
to verify that SHASUMS256.txt has not been tampered with.
To verify SHASUMS256.txt has not been altered, you will first need to import the GPG key of NW.js maintainer to create releases. Use this command to import the key:
$ gpg --keyserver pool.sks-keyservers.net --recv-keys 78680FA9E21BB40A
(Key fingerprint is 1E8B EE8D 5B0C 4CBC D6D1 9E26 7868 0FA9 E21B B40A)
Next, download the SHASUMS256.txt.asc for the release:
$ curl -O https://dl.nwjs.io/vx.y.z/SHASUMS256.txt.asc
After downloading the appropriate SHASUMS256.txt and SHASUMS256.txt.asc files,
you can then use gpg --verify SHASUMS256.txt.asc SHASUMS256.txt
to verify
that the file has been signed by an authorized member of the NW.js team.
Once verified, use the SHASUMS256.txt file to get the checksum for the binary verification command above.
License
NW.js
's code in this repo uses the MIT license, see our LICENSE
file. To redistribute the binary, see How to package and distribute your apps
Top Related Projects
:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
Build smaller, faster, and more secure desktop applications with a web frontend.
Portable and lightweight cross-platform desktop application development framework
A library for building cross-platform native desktop applications with Node.js and CSS 🚀. React NodeGui : https://react.nodegui.org and Vue NodeGui: https://vue.nodegui.org
:zap: Native, high-performance, cross-platform desktop apps - built with Reason!
Rust bindings for the FLTK GUI library.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot