WebAssembly.Instance.prototype.exports

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since October 2017.

The exports read-only property of the WebAssembly.Instance object prototype returns an object containing as its members all the functions exported from the WebAssembly module instance, to allow them to be accessed and used by JavaScript.

Examples

Using exports

After fetching some WebAssembly bytecode using fetch, we compile and instantiate the module using the WebAssembly.instantiateStreaming() function, importing a JavaScript function into the WebAssembly Module in the process. We then call an Exported WebAssembly function that is exported by the Instance.

js
const importObject = {
  my_namespace: {
    imported_func(arg) {
      console.log(arg);
    },
  },
};

WebAssembly.instantiateStreaming(fetch("simple.wasm"), importObject).then(
  (obj) => obj.instance.exports.exported_func(),
);

Note: You can also find this example as instantiate-streaming.html on GitHub (view it live also).

Specifications

Specification
WebAssembly JavaScript Interface
# dom-instance-exports

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
exports

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also