NW.js for Building Desktop Apps Using Web Technologies

NW.js is a runtime for building desktop applications using Web technologies.

Like WebViews for iOS/Android, NW.js leverages the latest in web technologies (Chromium and io.js) to provide a complete platform for building fully-featured desktop applications using the same technologies used for the Web.

Web applications are the past, present, and future, but there are some cases where it’s not recommended to host an application on a remote server. With the arrival of HTML5, we now have low-level functionality added to modern browsers, like the ability to read and write files to a computer’s file system.

That opens up the possibility to create offline Single Page Applications (SPAs) using a web browser as a platform.

That presents some interesting possibilities, such as the ability to deploy your application on multiple operating systems.

History

Let me provide a little insight into the history of the NW.js project. The node-webkit project (its original name) was created at Intel and open-sourced in 2011 in an attempt to solve the problems encountered in creating SPA offline applications.

The project provides developers with a WebKit browser that has been extended with the the ability to control user interface elements, normally off-limits. The browser’s security configuration is relaxed, because it assumes that the application code you’re running is trusted. And, most interestingly, the browser integrates Node.js, allowing developers to leverage a wide array of functionality other than what HTML5 APIs provide.

The rebranding of the node-webkit project into NW.js was done because the webkit browser was replaced by Chromium and instead of Node.js the project uses io.js.

Chromium is an open-source browser project that was started in the development of Chrome and Chrome OS. You can look at Chromium as the development release and Chrome as the stable release, hence the histories of the two are intertwined.

io.js is an open-source project that began as a fork of Joyent’s Node.js. Its aim is to have more frequent releases and faster adoption of the latest developments of the V8 runtime. It also remains compatible with the Node Package Manager (npm) ecosystem.

Installation

NW.js can be installed on all major platforms, Windows, OS X and Linux. It supports both x32 and x64 platforms. Installing it is a breeze. You can find a downloads section on the project’s page which supplies a number of archives containing ready-to-run NW.js binaries with software libraries they depend on.

Once you have the appropriate archive you’ll need to locate the NW.js binary. For Windows the binary name is nw.exe, for Linux is nw and for OS X, which comes packaged in an application bundle, the binary is located inside in the Contents/MacOS folder and is called nwjs (/path/to/nwjs.app/Contents/MacOS/nwjs).
Installing is as easy as placing the extracted folder in the place of your choosing.

NW.js has both the Browser JavaScript APIs and the Node.js APIs. It enables you to build desktop applications the same way you build web apps.
If you are used to coding classic web apps, you might be a bit baffled as it’s possible within a script tag to access Node.js APIs.

An advantage with going desktop instead of a browser is that you can do much more than what a simple web app allows you to do, thus making it easier to sell your application. For example, there are already games on Steam that are just web apps, but using NW to run “natively” on the desktop.

You do not need a SDK or full blown IDE, just use your usual tools. Write HTML and JS files as you would normally do but consider NW as the browser. Then package and distribute your app and the user won’t notice or care that they are using, in essence, a browser.

Distribution

From a distribution perspective there are two ways you can do that. You can either have everything packaged inside the app (that includes NW.js ~100MB) or trust the users to install NW.js on their machines. I personally, don’t think that asking or trusting the users to have NW.js properly installed on their local machines is an option, as easy as installing NW.js can be. It would present a too higher risk for the entire functioning of the app to consider this as a viable option, even though having another ~100MB added to the app is not the ideal scenario either.

Alternatives

NW.js is not the only solution out there; we see more and more alternatives rolling out as time passes by. Some of the more popular ones are TiDeSDK, Sencha Desktop Manager or Electron (previously named Atom Shell).

TiDeSDK is a more complete solution that aims to bring under one roof all platforms to create desktop applications.

Sencha Desktop Manager is included with Sencha Complete and in essence aims to do the same thing as TiDeSDK with one big difference: it only supports Windows and Mac OS X.

Electron is the platform over which the Atom text editor was built. It solves the same problems as NW.js but it does it somewhat differently. It doesn’t integrate Chromium, but instead uses libchromiumcontent to access Chromium’s Content API.

Conclusion

Frameworks like NW.js have been out there for a while now but only recently began to grow in popularity. We are seeing more and more apps built using NW.js or other similar frameworks (Wunderlist, Atom, Brackets, etc) that look and feel like native apps. I believe the decisive moment that made these types of frameworks viable was when NodeJS was blended in, giving app developers the possibility to mimic basically all of the native features so far forbidden for a classic web app.

Bogdan Balc

Bogdan Balc

Bogdan Balc is a Technical Lead in 3Pillar Global’s Cluj-Napoca office. His specialties are web technologies, including HTML5, CSS3, JavaScript. He worked on a number of projects with various JS frameworks like SproutCore, Backbone, AngularJS. In his current role he leads a team involved in refactoring and improving an AngularJS finance application for both web and mobile. He has 8+ years of experience working on web applications from IE 6 to the latest and greatest browsers that we have this days.

3 Responses to “NW.js for Building Desktop Apps Using Web Technologies”
  1. Vijay on

    Hi Bogdan,
    Iam a Test Engineer working for one of the product based company.
    We have an Desktop based application which is NW.JS developed using web technologies with Chromium embedded framework.
    I need to automate this application using selenium Web Driver
    My question is: Is it possible to automate this application using selenium web
    driver or do we have any other tool for automating this application.
    Waiting for your reply

    Thanks,
    Vijay

    Reply
    • Bogdan Balc on

      Hi Vijay,

      You can definitely use Selenium WebDriver but there are also some alternatives.

      ChromeDriver is a standalone server which implements WebDriver’s wire protocol for Chromium that can be used with Selenium.

      There is also a nifty alternative using mocha with chrome-remote-interface node.js module. Here is an article by Yaniv Kessler Automate NW.js UI testing

      Hope this helps,
      Bogdan

      Reply
      • Vijay on

        Hi,
        The thing is that, the browser is customized , so when i invoke my application, it does not open in any of the traditional browsers, instead it opens in a window which is developed using NW.js Technology(CSS3.0,HTML5.0,JS,node.js and c++ technologies.
        My application is embedded inside this window which is based on chromium
        I tried to automate thru various testing tools the basic login functionality , but the test tools identifies only the main window, and it never identifies the objects inside the main window.
        My problem is until and unless, the tool identifies the inner objects, i cannot proceed with my automation with any of the existing testing tools
        like UFT,TestComplete,White,Selenium,WinTask…
        Hope i made it clear to you.

        Reply
Leave a Reply

Related Posts

The 3 Keys to Building Products That Drive Retention –... I had the privilege of being invited to speak at the Wearable Technology Show in Santa Clara this week, where I gave a bit of a reprisal of a talk I d...
High Availability and Automatic Failover in Hadoop Hadoop in Brief Hadoop is one of the most popular sets of big data processing technologies/frameworks in use today. From Adobe and eBay to Facebook a...
3Pillar CEO David DeWolf Quoted in Enterprise Mobility Excha... David DeWolf, Founder and CEO of 3Pillar Global, was recently quoted in a report by Enterprise Mobility Exchange on the necessity of understanding and...
How the Right Tech Stack Fuels Innovation – The Innova... On this episode of The Innovation Engine podcast, we take a look at how choosing the right tech stack can fuel innovation in your company. We'll talk ...
The Road to AWS re:Invent 2018 – Weekly Predictions, P... For the last two weeks, I’ve been making predictions of what might be announced at AWS’ upcoming re:Invent conference. In week 1, I made some guesses ...