AssemblyScript has included support for targeting WASI since version 0.10.0. To use it, add import "wasi" at the top of your entrypoint file.

Let's walk through a simple hello world example using the latest AssemblyScript runtime (at the time of this writing, it is AssemblyScript runtime included in version 0.19.x):


import "wasi"
// Import the WASI environment and additional WASI-enabled APIs
console.log('Hello World!\n');
// Call AssemblyScript console.log which in turn calls WASI

This uses as-wasi as a dependency to make working with the AssemblyScript WASI bindings easier. Then, you can run:

asc wasi-hello-world.ts -b wasi-hello-world.wasm

to compile it to wasm, and

wasmtime wasi-hello-world.wasm

to run it from the command-line. Or you can instantiate it using the Wasmtime API.


It can also be packaged using a package.json file:

  "name": "wasi-hello-world",
  "version": "1.0.0",
  "description": "Hello world in Wasi with AS and as-wasi",
  "main": "index.js",
  "scripts": {
    "build": "asc wasi-hello-world.ts --target helloworld",
    "wasmtime": "wasmtime ./build/wasi-hello-world.wasm"
  "author": "Aaron Turner",
  "contributors": [
    "Jairus Tanaka (JairusSW)"
  "license": "MIT",
  "devDependencies": {
    "assemblyscript": "^0.20.7"
  "dependencies": {}

You can also browse this source code online and clone the wasmtime repository to run the example locally.