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.
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 In Chinese, 融 means to merge and harmonize. Rong fuses JavaScript engines with Rust native code, unifying diverse runtimes under a single, elegant 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.
Expose Rust structs to JavaScript with #[js_export], #[js_class], and #[js_method] — constructors, getters, setters, and static methods, all type-checked by Rust.
First-class Promise and async iterator integration so JavaScript and Rust futures interleave naturally across the engine boundary.
Choose your execution model explicitly: shared() workers for stateless work, pinned() workers for keyed state that must live on the same long-lived runtime.
Continuously tested on Windows, Linux, and macOS — QuickJS everywhere, system JavaScriptCore on macOS, and source-built JSC consumers on all three.
Type definitions ship as @rongjs/rong on npm, and @rongjs/rong-skill packages an installable agent skill with generated API references.
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.
Lightweight and fast. The default engine for the Rong CLI on desktop hosts, paired with the aws-lc TLS backend.
Links the system JavaScriptCore.framework on macOS and iOS, or pinned source-built WebKit/JSCOnly artifacts on macOS, Linux, and Windows.
The HarmonyOS JavaScript engine, for aarch64 OpenHarmony targets with the ring TLS backend.
The Rong core provides the unified API, type system, memory management, and async layer. Engines and built-in modules plug in beneath it.
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-ohosCommon runtime tasks ship in the box — timers, HTTP, file system, storage, workers, Redis, SQLite, S3, and more. Click a module to read its API reference.
rong_timer setTimeout, setInterval, async timers rong_http HTTP client/server, fetch API rong_fs File system operations rong_console Console logging & debugging rong_url URL parsing & manipulation rong_buffer Binary data handling rong_event Event emitter & handling rong_abort AbortController & signals rong_encoding Text encoding / decoding rong_assert Assertion utilities rong_exception Exception handling rong_storage Storage APIs rong_stream Stream APIs rong_compression Compression & decompression rong_command Subprocess & shell execution rong_worker JavaScript worker threads rong_cron Cron parsing & scheduled jobs rong_redis Redis client APIs rong_sqlite SQLite APIs rong_s3 S3-compatible object storage Rong ships to crates.io and npm, with tooling for TypeScript users and AI agents.
The runtime itself, plus per-module crates published in dependency order from a single release workflow.
npmTypeScript type definitions for the Rong runtime, so JS authored for Rong gets full editor support.
npmAn installable agent skill with self-contained docs and generated API references for AI coding agents.
CLILocal runtime execution and REPL workflows, with engine selection via Cargo features.
@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-developerWrite Rong JavaScript scripts, choose the right public APIs, adapt examples, run rong_cli, and compile bytecode.
rong-module-authorWrite 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.
Embed a runtime, expose Rust-driven APIs, and scale with worker pools — across every supported engine.