There are plenty of Rust frameworks that handle this interface for you, including calling Rust functions from JS and JS functions from Rust.