v0.4.1 · See what's new

One JavaScript API.
Every engine, in Rust.

Rong (融) is a JavaScript runtime for Rust with a unified API over QuickJS, JavaScriptCore, and ArkJS — built for embedding, Rust-driven JS APIs, and long-lived worker runtimes.

cargo add rong --features quickjs,tls-aws-lc
  • QuickJS
  • JavaScriptCore
  • ArkJS
3 JavaScript engines
20 built-in modules
1.90+ Rust toolchain (2024 edition)
MIT / Apache-2.0 dual licensed
Why Rong

Fusion, harmony, and flow — by design.

In Chinese, 融 means to merge and harmonize. Rong fuses JavaScript engines with Rust native code, unifying diverse runtimes under a single, elegant API.

Unified API

Write once, run anywhere. The same Rust code drives QuickJS, JavaScriptCore, and ArkJS — engines are selected at build time, with no engine-specific branches in your code.

Declarative class bindings

Expose Rust structs to JavaScript with #[js_export], #[js_class], and #[js_method] — constructors, getters, setters, and static methods, all type-checked by Rust.

Async / await

First-class Promise and async iterator integration so JavaScript and Rust futures interleave naturally across the engine boundary.

Worker pools

Choose your execution model explicitly: shared() workers for stateless work, pinned() workers for keyed state that must live on the same long-lived runtime.

Cross-platform CI

Continuously tested on Windows, Linux, and macOS — QuickJS everywhere, system JavaScriptCore on macOS, and source-built JSC consumers on all three.

TypeScript & tooling

Type definitions ship as @rongjs/rong on npm, and @rongjs/rong-skill packages an installable agent skill with generated API references.

Multi-engine support

Three engines, one codebase.

Engines are mutually exclusive and chosen at build time — if multiple engines are enabled, the build fails fast. The library ships no default; downstream crates select an engine and TLS backend explicitly.

Default · Desktop

QuickJS

Lightweight and fast. The default engine for the Rong CLI on desktop hosts, paired with the aws-lc TLS backend.

Apple system + source builds

JavaScriptCore

Links the system JavaScriptCore.framework on macOS and iOS, or pinned source-built WebKit/JSCOnly artifacts on macOS, Linux, and Windows.

HarmonyOS / OpenHarmony

ArkJS

The HarmonyOS JavaScript engine, for aarch64 OpenHarmony targets with the ring TLS backend.

Architecture

A unified core over swappable engines.

The Rong core provides the unified API, type system, memory management, and async layer. Engines and built-in modules plug in beneath it.

Rong Core
Unified APIType SystemMemory ManagementAsync / Await
QuickJS JavaScriptCore ArkJS
Built-in Modules & Extensions
TimerHTTPFSConsoleS3SQLiteRedisWorker
Quick start

From zero to evaluating JS in seconds.

Add the dependency, pick an engine, and run JavaScript from Rust — or expose Rust classes to JavaScript.

use rong::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a JavaScript runtime and context
    let rt = RongJS::runtime();
    let ctx = rt.context();

    // Execute JavaScript directly
    let result: i32 = ctx.eval(Source::from_bytes(b"2 + 3"))?;
    println!("Result: {}", result); // Result: 5

    Ok(())
}
use rong::{Rong, RongJS, Source};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // shared() for stateless work on any available worker;
    // pinned::<K, S>() keeps keyed work on the same runtime.
    let rong = Rong::<RongJS>::builder().shared().workers(2).build()?;

    let value: i32 = rong.call(|runtime, _receiver| async move {
        let ctx = runtime.context();
        ctx.eval(Source::from_bytes(b"21 * 2"))
    }).await?;

    println!("JS result: {value}"); // JS result: 42
    Ok(())
}
use rong::*;
use rong::{js_class, js_export, js_method};

#[js_export]
struct Point { x: i32, y: i32 }

#[js_class(rename = "Point2D")]
impl Point {
    #[js_method(constructor)]
    fn new(x: i32, y: i32) -> Self { Self { x, y } }

    #[js_method(getter, enumerable)]
    fn x(&self) -> i32 { self.x }

    #[js_method(rename = "moveBy")]
    fn move_by(&mut self, dx: i32, dy: i32) {
        self.x += dx;
        self.y += dy;
    }

    // Static method: Point2D.origin()
    #[js_method]
    fn origin() -> Self { Self { x: 0, y: 0 } }
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let rt = RongJS::runtime();
    let ctx = rt.context();

    // Register once, then use from JavaScript:
    //   const p = new Point2D(1, 2); p.moveBy(3, 4);
    ctx.register_class::<Point>()?;
    Ok(())
}
[dependencies]
# Engines are mutually exclusive — pick one, plus a TLS backend.
# Desktop: tls-aws-lc · HarmonyOS/OpenHarmony: tls-ring
rong = { version = "0.4", features = ["quickjs", "tls-aws-lc"] }
# Run the Rong CLI / REPL — QuickJS + aws-lc by default on desktop
cargo run -p rong_cli

# Switch to JavaScriptCore explicitly
cargo run -p rong_cli --no-default-features --features jscore,tls-aws-lc

# Build for ArkJS on OpenHarmony targets
cargo build --no-default-features --features arkjs,tls-ring \
  --target aarch64-unknown-linux-ohos
Agent skills

Teach your AI agent Rong.

@rongjs/rong-skill bundles two installable agent skills — self-contained SKILL.md documents with generated API references, for any agent runtime that supports file-based skills.

rong-runtime-developer

Write Rong JavaScript scripts, choose the right public APIs, adapt examples, run rong_cli, and compile bytecode.

rong-module-author

Write or edit Rust modules that expose Rong APIs, classes, functions, type conversions, and JavaScript errors.

npx @rongjs/rong-skill install

Use --project for a project-local install, or --skill <name> to install just one. The skills share their source with the module API docs on this site — one source of truth.

Bring JavaScript into your Rust application.

Embed a runtime, expose Rust-driven APIs, and scale with worker pools — across every supported engine.