User Guide

This guide will introduce the wasmer-cli tool and show a few common workflows. The wasmer client can install packages, manage WebAssembly dependencies, and expose WebAssembly behavior with commands.

What is wasmer?

The wasmer ecosystem makes WebAssembly more accessible to developers. The system is enabled by a couple tools:

The tool comes bundled with wasmer: the WebAssembly runtime, but it works great with the other server-side runtimes and the web!

The name wasmer is an abbreviation for WebAssembly Package Manager, but then name represents the ecosystem of packages and the tools.

Installation

The wasmer-cli tool be installed using the Wasmer installer. Wasmer is useful for running WebAssembly modules installed by wasmer-cli. See installation instructions for installing wasmer-cli.

Basic Usage

With the tools installed, one can easily start using universal wasm binaries by using the install command of wasmer-cli:

$ wasmer run syrusakbary/cowsay

Installing a package creates a local package directory called wasmer_packages where all packages are installed. While in a directory with wasmer packages, one may execute them with the run command:

$ wasmer run cowsay hello wasmer!
 _____________
< hello wasmer! >
 -------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
               ||----w |
                ||     ||

Package with wasmer.toml

The manifest file enables one to publish a package to the wasmer.io public registry.

Login is required for publishing. Signup for an account at wasmer.io and login to the server with login command.

The reference shows all the required fields for the manifest, but it's easy to get started with init command. init will guide you through the process of setting up a wasmer manifest.

$ wasmer init

This command generates a wasmer manifest file with the information you've provided:

[package]
name = "username/my_package"
version = "0.1.0"
description = ""
license = "MIT"

[[module]]
name = "my_app"
source = "path/to/app.wasm"

Publish the project to wasmer.io!

$ wasmer publish

Commands

Commands (not to be confused with wasmer-cli subcommands) are a feature that enables easily executing wasm code from a wasmer package.

Commands are what allows one to call the run subcommand, like above when running wasmer run cowsay hello wasmer!.

A command requires a name and module to reference:

[[command]]
name = "my_cmd"
module = "my_app"

Now called wasmer run my_cmd will execute the module defined with the name my_app. Under the hood, wasmer-cli calls wasmer, the WebAssembly server runtime.