SkillAgentSearch skills...

Nodekit

{NK} NodeKit is the universal, open-source, embedded engine that provides a full ES5 / Node.js instance inside desktop and mobile applications for macOS, iOS, Android, and Windows.

Install / Use

/learn @nodekit-io/Nodekit
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

http://nodekit.io {NK} NodeKit is the universal, open-source, embedded engine that provides a full Node.js instance inside desktop and mobile applications for macOS, iOS, Android, Fire OS, and Windows.

For application developers, the backend can be written in pure Node javascript code, the front-end in the architecture of your choice including but not limited to Atom Electron API, Facebook React, Express, etc.)

{NK} NodeKit enables applications developed for Node to developed once and then run without alteration for any of the above platforms as well as in the browser.

{NK} NodeKit

Join the chat at https://gitter.im/nodekit-io/nodekit {NK} Roadmap Carthage compatible NuGet compatible JitPack compatible Contact

Installation

Make sure you have Node.js installed (between v4 and v6).

Optimal: install Node.js version 6.7 or later and npm 3.10 or later using nvm

npm install -g nodekit-cli

Create and run a Sample Application (Apple)

(Make sure you have Xcode, Xcode command line tools and CocoaPods installed)

nodekit create myapp io.nodekit.myapp myapp
cd myapp
nodekit platform add macos
nodekit platform add ios
nodekit build
nodekit run

Create and run a Sample Application (Android)

(WIP: Should compile but may not be fully functional. Make sure you have Android Studio installed)

nodekit create myapp io.nodekit.myapp myapp
cd myapp
nodekit platform add android
nodekit build
nodekit run

Apple iOS and OS X platforms source code

git clone https://github.com/nodekit-io/nodekit-darwin.git

Open src/nodekit.xcodeproj in Xcode. You will see 4 build targets, 2 for the frameworks (on iOS and OSX respectively) and 2 for the sample app.

Build the nodekit-Mac-sample for My Mac or the nodekit-iOS-sample for the iOS Simulator (e.g., iPhone 6) and run. All the Node.js tests should run and you should see the results as a graphical chart.

To switch to the sample app, change the package.json main entry to point to app/sample/index.js instead of test/index.js

Windows platforms source code

git clone https://github.com/nodekit-io/nodekit-windows.git

Open in Visual Studio

Android and Amazon Fire OS platforms source code

git clone https://github.com/nodekit-io/nodekit-android.git

Open in Android Studio.

Open src/nodekit-windows.sln in Visual Studio Community 2015 and follow the instructions equivalent to above.

Simple Configuration

Two lines in main.swift to launch an embedded WebKit view and start the NodeKit engine (already included for you in the sample).

import NodeKit
NKNodeKit.start();

Two lines in main.cs to launch an embedded Edge view and start the NodeKit engine (already included for you in the sample).

using io.nodekit
NKNodeKit.start();

Then just make sure any standard Node application is in the app/ directory. This application will run in the main process (a hidden but highly performant JavaScript engine such as Nitro WKWebView, JavaScriptCore, Chakra or ChakraCore). The first thing the application typically does is open a renderer window, very similar to Atom Electron:

const app = require('electro').app;
const BrowserWindow = require('electro').BrowserWindow
app.on('ready', function() {
  var window = new BrowserWindow();
});

The sample app includes a built in web server for serving static and dynamic content; on iOS this can be an http server over a localhost port, but on OSX you may want to use no ports at all and just use built in protocol server.

Build in Xcode for both iOS and Mac targets.

Build in Visual Studio or using MBuild for all projects in the solution.

Three Main Components in {NK} NodeKit

{NK} Scripting

{NK} Scripting is an advanced JavaScript - Native (Swift, Objective-C, C#, C++, Visual Basic) bridge for hybrid applications. It builds upon the core platform bridges such as JavaScriptCore or ChakraCore, but abstracts the implementation details and standardizes across scripting engine families. It is the foundation of {NK} NodeKit and can be used without {NK} Electro or {NK} Core or with substitutes.

{NK} Electro

{NK} Electro is an API for {NK} NodeKit applications that facilitates application lifecycle and user interface tasks. It is inspired by the Atom Electron API, and is generally a lighter-weight but code-compatible subset. It requires {NK} Scripting but can be used without {NK} Core if you dont need all the Node features and just want a lightweight way of building universal desktop and mobile apps, a bit like Cordova but with {NK} Scripting features.

{NK} Core

{NK} Core takes the above a step further and provides a light-weight but fully functional version of Node for {NK} NodeKit applications. It leverages the original Node source for all the Javascript components, but generally backs with different bindings to leverage each platform's built-in javascript engine(s) instead of the V8 engine. Where possible native code has been moved to Javascript. It requires {NK} Scripting and is generally paired with {NK} Electro as here, but technically you could replace {NK} Electro with your own code or plugin to open and manage the window lifecycle.

Distribution

The {NK} nodekit-darwin repository contains an XCode project with all the above components (zero dependencies) that compiles to an iOS 8 + and OS X 10.9 + dynamic framework. Versions for Android are in active development.

The {NK} nodekit-windows repository contains a Visual Studio solution and a set of MSBuild projects with all the above components (zero dependencies) that compiles to Universal Windows Platform and (coming soon) .NET Framework 4.6 binaries (for WPF applications).

The framework / DLL files (containing binary code and embedded resources like the core Node.js javascript code) can just be included in any corresponding iOS, OS X or Windows applications. See the sample app for an example. You can thus compile and create your own projects; no app store consumer really needs to know how you built it unless you want to tell them or modify the {NK} NodeKit source.

Is it really Node ?

YES for all the javascript portions (and most of Node is written in javascript, of course). NO for all the V8 bindings.

We include the direct source files from Node.js source directly in NodeKit (you can find them in the framework package in a folder called lib). Then we add our own bindings to replace the V8 native ones, writing them in javascript as much as possible, with a few native calls for the really platform specific stuff like sockets, timers, and the file system. These bindings have exactly the same API signatures as the Node versions so are plugin replacements.

This means most Node packages will work without modification. Those that require node-gyp native bindings to V8 would require an alternative.

How does it relate to Cordova, Electron, CrossWalk, XWebView and NW ?

Actually, we've built upon the shoulders of all of these and similarly on the excellent Nodelike and Nodyn projects (both no longer maintained) and even Microsoft's Node fork for ChakraCore, by taking the approach of re-writing the bindings to V8. However, we've written or re-used as much code in JavaScript as far as possible. The whole theory of the Node ecosystem is that JavaScript is pretty fast, in fact when compiled like we can with the Nitro engine used by {NK} NodeKit its really really fast. Bridging back and forth to native tends to introduce latency which we like to avoid except where essential or where done for us by the emerging HTML5 / ES5 /ES6 features of most modern JavaScript engines.

The real motivation for us however, wasn't speed of execution, but rather we didnt want to include a large 48Mb executable for Chromium or its javascript engines in every app download... when most modern operating systems already include an ES5 engine.

So on iOS and Macs we use JavaScriptCore or Nitro... on Windows we use Chakra or ChakraCore... and on Android and Linux we use Chromium/V8. Since the Node JavaScript source runs on each without patching (in some cases we add some polyfills), the only things we had to write (once per platform) were the bindings and again re

Related Skills

View on GitHub
GitHub Stars232
CategoryDevelopment
Updated9mo ago
Forks13

Security Score

87/100

Audited on Jun 15, 2025

No findings