11 releases

✓ Uses Rust 2018 edition

new 0.3.4 Jul 9, 2020
0.3.3 May 27, 2020
0.3.1 Mar 24, 2020
0.3.0 Nov 2, 2019
0.1.0 Jul 22, 2019

#3 in Emulators

Download history 20/week @ 2020-03-16 40/week @ 2020-03-23 72/week @ 2020-03-30 44/week @ 2020-04-06 40/week @ 2020-04-13 15/week @ 2020-04-20 9/week @ 2020-04-27 12/week @ 2020-05-04 34/week @ 2020-05-11 15/week @ 2020-05-18 94/week @ 2020-05-25 118/week @ 2020-06-01 35/week @ 2020-06-08 27/week @ 2020-06-15 11/week @ 2020-06-22 30/week @ 2020-06-29

164 downloads per month
Used in 6 crates (via katex)

MIT license

74K SLoC

C 68K SLoC // 0.0% comments Rust 6K SLoC // 0.1% comments


Crates.io docs.rs [Build Status

A Rust wrapper for QuickJS.

QuickJS is a new, small Javascript engine by Fabrice Bellard and Charlie Gordon. It is fast and supports the full ES2020 specification.

This crate allows you to easily run and integrate with Javascript code from Rust.


quick-js = "0.3.3"
use quick_js::{Context, JsValue};

let context = Context::new().unwrap();

// Eval.

let value = context.eval("1 + 2").unwrap();
assert_eq!(value, JsValue::Int(3));

let value = context.eval_as::<String>(" var x = 100 + 250; x.toString() ").unwrap();
assert_eq!(&value, "350");

// Callbacks.

context.add_callback("myCallback", |a: i32, b: i32| a + b).unwrap();

    // x will equal 30
    var x = myCallback(10, 20);

Optional Features

The crate supports the following features:

  • chrono: chrono integration

    • adds a JsValue::Date variant that can be (de)serialized to/from a JS Date
  • bigint: arbitrary precision integer support via num-bigint

  • log: allows forwarding console.log messages to the log crate. Note: must be enabled with ContextBuilder::console(quick_js::console::LogConsole);

  • patched Enabled automatically for some other features, like bigint. You should not need to enable this manually. Applies QuickJS patches that can be found in libquickjs-sys/embed/patches directory.


By default, quickjs is bundled with the libquickjs-sys crate and automatically compiled, assuming you have the appropriate dependencies.

Windows Support

Windows is only supported with the MSYS2 environment and x86_64-pc-windows-gnu target architecture.

If you have MSYS2 installed and the MSYS bin directory in your path, you can compile quickjs with cargo build --target="x86_64-pc-windows-gnu".

The target can also be configured permanently via a cargo config file or the CARGO_BUILD_TARGET env var.

System installation

To use the system installation, without the bundled feature, first install the required dependencies, and then compile and install quickjs.

# Debian/Ubuntu: apt-get install -y curl xz-utils build-essential gcc-multilib libclang-dev clang
mkdir quickjs 
curl -L https://bellard.org/quickjs/quickjs-2019-07-09.tar.xz | tar xJv -C quickjs --strip-components 1
cd quickjs
sudo make install

You then need to disable the bundled feature in the libquickjs-sys crate to force using the system version.