wasm-bindgen

Easy support for interacting between JS and Rust.

18 releases

new 0.2.16 Aug 13, 2018
0.2.15 Jul 26, 2018
0.2.11 May 24, 2018
0.2.7 Apr 28, 2018
0.1.0 Mar 6, 2018

#6 in WebAssembly

Download history 259/week @ 2018-05-21 313/week @ 2018-05-28 240/week @ 2018-06-04 380/week @ 2018-06-11 246/week @ 2018-06-18 207/week @ 2018-06-25 375/week @ 2018-07-02 225/week @ 2018-07-09 337/week @ 2018-07-16 541/week @ 2018-07-23 661/week @ 2018-07-30 466/week @ 2018-08-06 593/week @ 2018-08-13

1,614 downloads per month

wasm-bindgen

Facilitating high-level interactions between wasm modules and JavaScript.

Build Status Build status API Documentation on docs.rs

Import JavaScript things into Rust and export Rust things to JavaScript.

#![feature(use_extern_macros)]

extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;

// Import the `window.alert` function from the Web.
#[wasm_bindgen]
extern {
    fn alert(s: &str);
}

// Export a `greet` function from Rust to JavaScript, that alerts a
// hello message.
#[wasm_bindgen]
pub fn greet(name: &str) {
    alert(&format!("Hello, {}!", name));
}

Use exported Rust things from JavaScript with ECMAScript modules!

import { greet } from "./hello_world";

greet("World!");

Guide

📚 Read the wasm-bindgen guide here! 📚

License

This project is licensed under either of

at your option.

Contribution

See the "Contributing" section of the guide for information on hacking on wasm-bindgen!

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

MIT/Apache-2.0 license

Dependencies

Reverse deps