Axway AMPLIFY Blogs

The Leading Resource for All THings Mobile & Data Integration

Titanium Desktop – Node.js Prototype

0 Flares 0 Flares ×
A few weeks ago we received a series of questions from the community about using Node.js with Titanium Desktop. Using a remote Node.js server with the Titanium mobile and/or desktop applications is not much different that working with any remote service. Working with a local Node.js server however is somewhat problematic in that most desktop machines do not have a local Node instance. That being said, while Titanium Desktop (as it stands today) does not bundle Node.js that doesn’t mean you can’t. Or at least that was my theory before kicking off a prototype a few days ago. screenshot To make Node.js useful from a local desktop development perspective we need to assure our app always has access to a Node.js instance. To accomplish this I started by compiling Node for OSX and Linux and dropping the resulting binaries into my projects default Resources directory. Items within the Resources directory are bundled with our project when we package for distribution so that solves the first problem. OK so we can distribute Node with the app now, but that is not of much use to us unless we have the ability within our application to pass it a script, create a server, etc. One of the great things about Titanium Desktop is the ability to use and/or combine the usage of JavaScript, PHP, Python, and Ruby. For this project I settled on utilizing Python & JavaScript. I wrote a basic Python script that is included when the application loads. This script detects the running platform, tracks down the right Node binary, spins up a Node child process for us and passes it a script to get things started. When the instance is ready a callback is made to JavaScript land and the real fun can begin. In this prototype the custom script I have Node execute creates a server and starts listening for incoming connections. Interacting with that instance can be done via standard Ajax using whatever JavaScript library you’re most comfortable with. To demonstrate usage of this I’ve built a simple little Github application. With Node support comes access to the wonderful world of Node Modules. Use can use npm to install modules within a project’s Resources directory just as you would any other Node project. This prototype uses the node-github module to handle interation with the Github API within Node. We’ve open sourced the project so head on over to Github and grab the source. If you just want to run the packaged versions you can grab those builds here. Fork, experiment and enjoy!
0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Email -- 0 Flares ×


  1. Nice! :)

    Did you see this hack around using server-side Node.js and NowJs with webviews and events in Titanium?

  2. Cool …
    Last summer I tried to connect a TCPClient to a TCPServer written with Node.js … with no success … It is possible now to use Sockets btw Titanium Desktop and Node.js ?

  3. Ray

    Examples like these are great, I think all the language (php, python, ruby) should have an example github project that contains all the material from the instructions.

  4. Jan Renz

    As now Appcelerator can use node.js and native Webkit, would this be a nice setup for Term Kit ( ). Anyone feels like giving it a try…?

Comments are closed.

computer and tablet showing Appcelerator software
Start free, grow from there.
0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Email -- 0 Flares ×