Building desktop apps with node.js and web technologies

4th February 2014 | by Adam Beres-Deak | node.js, webkit, desktop apps

Native apps with web technologies are not a mobile-only thing anymore. The node-webkit project makes it possible to write standalone desktop apps with JavaScript, HTML5 and CSS3. The coolest thing about this is, that both server side (node.js) and client side (jQuery, AngularJS, etc.) JavaScript libraries can be used.

A few hours ago I found this project called node-webkit. It seems to be living and mature enough to use it. But since I don't need it now, I blog about it, so that I can remember it in the appropriate moment.

How does it work?

  1. Write your application.
  2. Create a zip file of all your assets (call it package.nw).
  3. You can just ship this file along with the node-webkit executable file
  4. Alternatively you can create an executable file from the package with a few dll files along
  5. If you want to have a single executable file, it's recommended to box the files with Enigma Virtual Box

Attack of the contexts

There is a concept which might be a little crazy at first sight. There are different contexts with different global object for node modules and UI windows. In the web context we have a window object (or many if we have multiple windows), which we don't have in a node module. If we have to reach the window object of the current UI context, we have to pass it to the node module. We get most of the problem with instanceof because the constructors like Array or Date are children of the context-dependent global object. After just quickly building a "hello world" app I can't really tell to what extent this can be a problem or difficulty.

Supported platforms

There are prebuilt binaries for Windows, OSX and Linux.

References:

by Adam Beres-Deak

Latest blog posts

Worth watching: Douglas Crockford speaking about the new good parts of JavaScript in 2014 20th October 2014

Automatically adjusting the height of a textarea to its content text 16th October 2014

Loading webfonts with high performance on responsive websites 8th October 2014

Loading web pages really fast - optimistic page loading with Instantclick.io 8th October 2014

Generating sound effects with client side JavaScript 6th April 2014