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

To create a program which can be run directly as a command, pass --runtime half to the AssemblyScript linker. This selects the half runtime, which ensures that the generated wasm module doesn't contain any extraneous exports. (This isn't strictly required today, but the handling of extraneous exports may change in the future, so it's encouraged. As a bonus, it also reduces code size.)

To create a program which can be loaded as a library and used from other modules, no special options are needed.

Let's walk through a simple hello world example.


import "wasi"

import {Console} from "as-wasi"
Console.log('Hello World!\n');

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 -b wasi-hello-world.wasm -t wasi-hello-world.wat --runtime half",
    "wasmtime": "wasmtime wasi-hello-world.wasm"
  "author": "Aaron Turner",
  "license": "MIT",
  "devDependencies": {
    "assemblyscript": "^0.10.0"
  "dependencies": {
    "as-wasi": "^0.1.1"

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