Skip to content

getWasmApi

getWasmApi(): object

Defined in: packages/runtime/src/wasm/wasi-types.ts:426

Resolve the WebAssembly namespace from globalThis at runtime.

Returns an object with compile and instantiate methods. Avoids requiring the dom lib at compile time so the package stays library-agnostic.

object

A typed view over globalThis.WebAssembly.

compile(binary): Promise<WasmModule>

Uint8Array

Promise<WasmModule>

instantiate(module, imports): Promise<WasmInstance>

WasmModule

Record<string, Record<string, unknown>>

Promise<WasmInstance>

Error if WebAssembly is not available in this environment.

const wa = getWasmApi()
const mod = await wa.compile(wasmBytes)