How to call wasm function compiled from rust using javascript?

Hi all,

I've got a rust function that takes a &str input and returns a String output, which I want to expose to javascript for a web page. I've built a wasm version of my library crate (GitHub - droundy/latex_snippet). Now I want to be able to use this function in javascript on my web page (also served from rust). I do not want to use npm, nor do I have Node.js installed.

Using wasm-pack I have built a wasm file and javascript bindings (that show up as latex_snippet.js), but I haven't been able to get those bindings to run in the browser, which doesn't seem to like the bit where it imports the wasm file. Can anyone point me to appropriate javascript to load a library written in rust?

I think --target web is for your use case. Without a Bundler - The `wasm-bindgen` Guide

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.