JavaScript target

Can Rust compile directly to JavaScript?

Yes, you can use the asmjs-unknown-emscripten target to compile to the asm.js subset of JavaScript.

You can also compile Rust to WebAssembly, which is supported by most current JavaScript engines and which improves in some ways over asm.js.

1 Like

If you want to compile for Node.js, you can use Neon.

Here's the main site for WASM usage in Rust. See also the Book and/or a framework like Seed for a complete experience. The repo for my website also has a number of examples of WASM projects.