Skip to content
A JavaScript runtime library for RTOS.
C Python C++ JavaScript CMake Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
deps fix: fix leak & add napi helper Dec 11, 2019
samples chore: update sample Dec 11, 2019
src fix: fix leak & add napi helper Dec 11, 2019
tools reactor: remove extra modules & add http napi test Dec 10, 2019
.gitignore add N-API support & optimize Nov 9, 2019
LICENSE chore: add and LICENSE Nov 4, 2019



rt-node is a lightweight JavaScript framework for RTOS, also support unix like systems for debugging.

The following runtime modules are built in:

  • timer
  • require
  • utils
  • console
  • N-API

N-API is supported in order to be compatible with different embed JavaScript engines, the following N-API features are WIP:

  • thread safe function


  • JerryScript, a lightweight JavaScript engine
  • rv, a tiny event loop library

JavaScript Sample


'use strict';
class Speaker {
  constructor(content) {
    this.content = content;
  say() {
module.exports = Speaker;


'use strict';
const Speaker = require('speaker');
const speaker = new Speaker('hello world');
setTimeout(() => {
}, 3000);

N-API Sample

'use strict';
// The curl module depends on libcurl, the source file is sample/unix/curl.c
const curl = require('curl');
const startTime =;
curl.get('', (body) => {
  console.log(`get body in ${ - startTime}ms`, body);


JavaScript sources are packaged in src/rtnode-snapshots.c/h, set JS_ROOT as your JavaScript sources root directory for cmake to package them, app.js is the entry of user code.

rtnode use CMake to build library or samples. The easiest way to build is as follows:

$ cmake -B./build -H. -DJS_ROOT=Your_js_files_root_directory
$ make -C./build -j8

The above commands will generate librtnode.a in ./build directory.

For cross compile, add the following flags:

  • CMAKE_C_COMPILER, full path for c compiler
  • CMAKE_SYSTEM_PROCESSOR, the name of the CPU CMake is building for
  • CMAKE_SYSTEM_NAME, set Generic to indicate cross compile

Here is an example for Xtensa toolchain:

$ cmake -B./build-xtensa -H. \
  -DCMAKE_C_COMPILER=xtensa-esp32-elf-gcc \
$ make -C./build-xtensa -j8


Currently support unix and esp-idf build framework.

For unix like systems

$ cmake -B./build -H. -DSAMPLE=unix -DJS_ROOT=./samples -DJERRY_PROFILE=es2015-subset
$ make -C./build
$ ./build/rtnode-unix/rtnode-unix # run sample

For esp-idf:

$ cmake -B./build-espidf -H. \
  -DCMAKE_C_COMPILER=xtensa-esp32-elf-gcc \
  -DSAMPLE=esp-idf \
  -DJS_ROOT=./samples \
$ make -C./build-espidf -j8

The esp-idf products will generate in ./build-espidf/rtnode-build, then use flash to flash the binaries that you just built onto your ESP32 board. For more information, please refer to the esp-idf document.



You can’t perform that action at this time.