# Where is init module when doing Rust to WebAssembly

**URL:** <https://discourse.mozilla.org/t/where-is-init-module-when-doing-rust-to-webassembly/136552>\
**Category:** Common Voice\
**Tags:** learning\
**Created:** [October 18, 2024, 8:38pm UTC](https://discourse.mozilla.org/t/where-is-init-module-when-doing-rust-to-webassembly/136552 "2024-10-18T20:38:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahesh\_Velankar](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Mahesh\_Velankar](https://discourse.mozilla.org/u/Mahesh_Velankar)\
**Post date:** [October 18, 2024, 8:38pm UTC](https://discourse.mozilla.org/t/where-is-init-module-when-doing-rust-to-webassembly/136552/1 "2024-10-18T20:38:19Z")

</div>

I am learning Rust to WebAssembly from this page : [https://developer.mozilla.org/en-US/docs/WebAssembly/Rust\_to\_Wasm](https://developer.mozilla.org/en-US/docs/WebAssembly/Rust_to_Wasm)  
I see this code for index.html file

```auto
<!doctype html>
<html lang="en-US">
  <head>
    <meta charset="utf-8" />
    <title>hello-wasm example</title>
  </head>
  <body>
    <script type="module">
      import init, { greet } from "./pkg/hello_wasm.js";
      init().then(() => {
        greet("WebAssembly");
      });
    </script>
  </body>
</html>

```

However i do not see an ‘init’ being exported from the hello\_wasm.js file in question.  
Moreover I changed the above javascript code to

```auto
<script type="module">
      import myinit, { greet } from "./pkg/hello_wasm.js";
      myinit().then(() => {
        greet("WebAssembly");
      });
    </script>

```

and still the javascript just works fine!.  
Please help me understand where is this ‘init’ coming from and how is it supposed to be used.  
Thanks  
-Mahesh

---

<div class="post-metadata">

**Author:** ![bozden](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/bozden/32/51381_2.png) [@bozden](https://discourse.mozilla.org/u/bozden)\
**Post date:** [October 18, 2024, 11:12pm UTC](https://discourse.mozilla.org/t/where-is-init-module-when-doing-rust-to-webassembly/136552/2 "2024-10-18T23:12:39Z")

</div>

I think you should post your question to the developer community here:  
[https://discourse.mozilla.org/c/developer-community/215](https://discourse.mozilla.org/c/developer-community/215)

Edit:  
There is this info on the following page:  
[https://rustwasm.github.io/docs/wasm-bindgen/examples/without-a-bundler.html](https://rustwasm.github.io/docs/wasm-bindgen/examples/without-a-bundler.html)

```auto
      // Note that the `default` import is an initialization function which**
      // will "boot" the module and make it ready to use.** Currently browsers
      // don't support natively imported WebAssembly as an ES module, but
      // eventually the manual initialization won't be required!
      import init, { add } from './pkg/without_a_bundler.js';
 ...

```

So it should be the default initializer generated. Like the “main” in other languages.
