Quickstart
Build WebAssembly (Wasm) applications and run them across any cloud, Kubernetes, datacenter, or edge.
In this tutorial:
- We'll use the Wasm Shell (
wash) CLI to build a simple "Hello world" HTTP server application as a WebAssembly (Wasm) component—written in the language of your choice. - Along the way, we'll start a developer loop that automatically deploys our application to a local wasmCloud environment.
Install wash
First, we need to install the latest version of wash (2.0.0-rc.6).
- macOS and Linux
- Windows
- Source
In your terminal, run the installation script to download and install the latest version of wash:
curl -fsSL https://raw.githubusercontent.com/wasmcloud/wash/refs/heads/main/install.sh | bashOn a successful installation, the script will return:
[INFO] Next steps:
1. Add /path/to to your PATH if not already included
2. Run 'wash --help' to see available commands
3. Run 'wash doctor' to verify your environment
4. Run 'wash new' to create your first WebAssembly componentTo quickly add wash to your PATH, you can move the binary to /usr/local/bin:
sudo mv ~/wash/wash /usr/local/bin/Clean up the source directory (optional):
rm -rf ~/washIn PowerShell, run the installation script to download and install the latest version of wash:
iwr -useb https://raw.githubusercontent.com/wasmcloud/wash/refs/heads/main/install.ps1 | iexNext steps:
1. Add /path/to to your PATH if not already included
2. Run 'wash --help' to see available commands
3. Run 'wash doctor' to verify your environment
4. Run 'wash new' to create your first WebAssembly componentTo add wash to your PATH by updating your PowerShell profile, add the filepath for wash returned above to your profile, replacing /path/to with your local filepath:
notepad $PROFILE$env:Path += ";C:\path\to\wash"You will need cargo to install from source.
git clone https://github.com/wasmcloud/wash.git
cd wash
cargo install --path .Pre-built binaries for macOS, Linux, and Windows are available on GitHub.
Verify that wash is properly installed and check your version for 2.0.0-rc.6 with:
wash -VIf wash is installed correctly, you will see a printout of all available commands and short descriptions for each.
If you ever need more detail on a specific command or sub-command just run wash <command> --help.
Choose your language
wasmCloud supports building WebAssembly components from any language that supports the WASI P2 target, including Go, Rust, TypeScript, and others.
wash depends on your local language toolchain for your language of choice.
- Choose the language you would like to use.
- Install the toolchain or verify that you have the correct versions.
- Rust
- TypeScript
- Go
- My language isn't listed
Install the Rust toolchain
Requirements:
- The Rust toolchain (always use the latest version)
- The
wasm32-wasip2target for Rust
On macOS or Ubuntu/Debian, you can use the official install script to download rustup, which will automatically install the Rust toolchain:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shOnce you've installed the Rust toolchain, use rustup to add the wasm32-wasip2 target:
rustup target add wasm32-wasip2Install the TypeScript toolchain
Requirements:
- npm v14.17+
- TypeScript v5.6+
- macOS
- Ubuntu/Debian
- My language isn't listed
On macOS, you can use Homebrew to install npm and Node.js. (See the official Node.js documentation for other options.)
brew install nodeOn Ubuntu, you can install npm (and Node.js) using the Node Version Manager (nvm). (See the official Node.js documentation for other options.) You can download and install nvm using the official installation script:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bashOnce the script completes, you may need to start a new shell session.
You can use nvm to install the latest Long-Term Service version of node:
nvm install --ltsIf you prefer working in a language that isn't listed here, let us know!
Once you've installed Node.js and npm, you can use npm to install TypeScript:
npm install -g typescriptInstall the Go toolchain
Requirements:
- Go 1.23.0+
- TinyGo (always use the latest version):
wasm-toolsv1.225.0
Due to incompatibilities introduced in wasm-tools v1.226.0 and higher, we strongly recommend using wasm-tools v1.225.0 when building Go projects. The easiest way to download wasm-tools v1.225.0 is via cargo: cargo install --locked wasm-tools@1.225.0
- macOS
- Ubuntu/Debian
On macOS, you can use Homebrew to install the Go toolchain. (See the official Go documentation for other options.)
brew install gobrew install tinygo-org/tools/tinygoYou will also need the wasm-tools utility.
On Ubuntu/Debian, Go 1.23+ isn't currently available via major package managers, but you can use curl or wget to download the Go toolchain from the official Go download page. (See the official Go documentation for other options.)
Before downloading, ensure that you do not have a previous version of Go installed. You can find an existing installation in the /usr/local/go directory.
Consult the download page and set environment variables specifying the appropriate version and architecture for your system. (The values below are examples.)
export GO_VERSION="1.23.4"export GO_ARCH="amd64"Download your file:
curl -O -L "https://golang.org/dl/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz"Find the appropriate checksum value for your file on the download page and validate the file. (The example below uses the checksum value for the v1.23.4 on amd64 download.)
echo -n "6924efde5de86fe277676e929dc9917d466efa02fb934197bc2eba35d5680971 *go${GO_VERSION}.linux-${GO_ARCH}.tar.gz" | shasum -a 256 --checkExtract the file:
tar -xf "go${GO_VERSION}.linux-${GO_ARCH}.tar.gz"You may need to change ownership on the new go directory:
sudo chown -R root:root ./goFinally, move the go directory to /usr/local:
mv -v go /usr/localOn Ubuntu/Debian, you can download TinyGo similarly. Refer to the TinyGo GitHub releases page to find the correct version and architecture and set environment variables accordingly. (The values below are examples—remember to always use the latest version of TinyGo.)
export TINYGO_VERSION="0.34.0"export TINYGO_ARCH="amd64"Now download the .deb file:
curl -O -L "https://github.com/tinygo-org/tinygo/releases/download/v${TINYGO_VERSION}/tinygo_${TINYGO_VERSION}_${TINYGO_ARCH}.deb"Install TinyGo from the .deb file:
sudo dpkg -i tinygo_${TINYGO_VERSION}_${TINYGO_ARCH}.debAdd TinyGo to your PATH:
export PATH=$PATH:/usr/local/binValidate the installation:
tinygo versionYou will also need the wasm-tools utility.
For the best experience, we strongly recommend using wasm-tools v1.225.0 and installing with cargo:
cargo install --locked wasm-tools@1.225.0Otherwise, download the binary for wasm-tools v1.225.0 for your architecture and add it to your PATH.
If you prefer working in a language that isn't listed here, let us know!
Create a new component
Now that we've installed wash and our language toolchain, it's time to create a new component project.
- Rust
- TypeScript
- Go
- My language isn't listed
In your terminal, run:
wash new https://github.com/wasmCloud/wash.git --name hello --subfolder examples/quickstart/hello-rustThis command...
- Creates a new project named
hello... - Based on an example found in the
wasmCloud/washGit repository... - In the subfolder
examples/quickstart/hello-rust.
Navigate to the hello project directory:
cd helloStart your developer loop
From our project directory, we'll run:
wash devThe wash dev command automatically builds your WebAssembly component and deploys it to a local wasmCloud environment. The terminal output should look like this:
INFO starting development session for project path="."
INFO building component path="."
INFO cargo build --target wasm32-wasip2 --color always completed in 0.14s
INFO HTTP server listening addr=0.0.0.0:8000
INFO development session started successfully
INFO listening for HTTP requests address=http://0.0.0.0:8000
INFO watching for file changes (press Ctrl+c to stop)...By default, the application will run on our local port 8000. In a new terminal tab, we can curl our application:
curl localhost:8000The application should return:
Hello from Rust!In your terminal, run:
wash new https://github.com/wasmCloud/wash.git --name hello --subfolder examples/quickstart/hello-tsThis command...
- Creates a new project named
hello... - Based on a template found in the
wasmCloud/washGit repository... - In the subfolder
examples/quickstart/hello-ts.
Navigate to the hello project directory:
cd helloStart your developer loop
From our project directory, we'll run:
wash devThe wash dev command automatically builds your WebAssembly component and deploys it to a local wasmCloud environment. The terminal output should look like this:
INFO starting development session for project path="."
INFO building component path="."
INFO running install command package_manager=npm install_args=["install"]
INFO npm install completed in 1.42s
INFO npm run build completed in 4.97s
INFO Generated project configuration at ./.wash/config.json
INFO HTTP server listening addr=0.0.0.0:8000
INFO development session started successfully
INFO listening for HTTP requests address=http://0.0.0.0:8000
INFO watching for file changes (press Ctrl+c to stop)...By default, the application will run on our local port 8000. In a new terminal tab, we can curl our application:
curl localhost:8000The application should return:
Hello from Typescript!You just ran a WebAssembly application in wasmCloud!
In your terminal, run:
wash new https://github.com/wasmCloud/wash.git --name hello --subfolder examples/quickstart/hello-goThis command...
- Creates a new project named
hello... - Based on a template found in the
wasmCloud/washGit repository... - In the subfolder
examples/quickstart/hello-go.
Navigate to the hello project directory:
cd helloStart your developer loop
From our project directory, we'll run:
wash devThe wash dev command automatically builds your WebAssembly component and deploys it to a local wasmCloud environment. The terminal output should look like this:
INFO starting development session for project path="."
INFO building component path="."
INFO go generate ./... completed in 6.46s
INFO tinygo build -o build/output.wasm -target wasip2 -wit-package wit -wit-world hello -gc conservative -scheduler asyncify -opt z -panic print -no-debug . completed in 8.12s
INFO HTTP server listening addr=0.0.0.0:8000
INFO development session started successfully
INFO listening for HTTP requests address=http://0.0.0.0:8000
INFO watching for file changes (press Ctrl+c to stop)...By default, the application will run on our local port 8000. In a new terminal tab, we can curl our application:
curl localhost:8000The application should return:
Hello from Go!You just ran a WebAssembly application in wasmCloud!
If you prefer working in a language that isn't listed here, let us know!
Make the application yours
Now we'll make a change to our code and see how the running application updates automatically.
- Rust
- TypeScript
- Go
- My language isn't listed
The Rust code for our component is found in src/lib.rs.
Open the file in your code editor and change the "Hello" message on line 19. You might modify the message to say hello from WebAssembly, your own name, or whatever else you like.
use wasmcloud_component::http;
struct Component;
http::export!(Component);
impl http::Server for Component {
fn handle(
_request: http::IncomingRequest,
) -> http::Result<http::Response<impl http::OutgoingBody>> {
Ok(http::Response::new("Hello from Rust!\n"))
Ok(http::Response::new("Hello from Wasm!\n"))
}
}The TypeScript code for our component is found in http-hello-world.ts.
Open the file in your code editor and change the "Hello" message on line 23. You might modify the message to say hello from WebAssembly, your own name, or whatever else you like.
// Write hello world to the response stream
outputStream.blockingWriteAndFlush(
new Uint8Array(new TextEncoder().encode('Hello from Typescript!\n'))
new Uint8Array(new TextEncoder().encode('Hello from Wasm!\n'))
);The Go code for our component is found in main.go.
Open the file in your code editor and change the "Hello" message in the handleRequest function. You might modify the message to say hello from WebAssembly, your own name, or whatever else you like.
func handleRequest(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello from Go!\n")
fmt.Fprintf(w, "Hello from Wasm!\n")
}If you prefer working in a language that isn't listed here, let us know!
Save the modified file. The wash dev automatically builds and deploys the updated component.
In the terminal, curl the application again:
curl localhost:8000Hello from Wasm!Next steps
We installed wash, built our first component, and ran our application locally with wash dev.
In our next tutorial, we'll add pluggable, reusable capabilities like key-value storage to our application.