---
title: "Building and Publishing Wasm Components | wasmCloud"
description: "Build and publish WebAssembly components with wash — compile to wasm32-wasip2, run with wash dev, and push to an OCI registry for wasmCloud deployment."
canonical: "https://wasmcloud.com/docs/wash/developer-guide/build-and-publish/"
---

Version: v2

# Building and Publishing Wasm Components

**Wasm Shell** (`wash`) is the comprehensive command-line tool for developing, building, and publishing WebAssembly components.

In this section of the Developer Guide, you'll learn how to:

- Compile your project to a WebAssembly component binary
- Publish your component to an OCI registry

> **Prerequisites**
>
> If you haven't completed the previous section on installing `wash`, creating a project, and starting a developer loop, we recommend [starting there](https://wasmcloud.com/docs/wash/developer-guide/).

## Building WebAssembly components

**Rust**

Use the `wash build` command from the root of a project directory to compile the component into a `.wasm` binary:

shell

```shell
wash build
```

By default, the compiled `.wasm` binary for a Rust project is generated at `/target/wasm32-wasip2/debug/`. The output path for the compiled `.wasm` binary [can be configured via `wash`'s configuration file](https://wasmcloud.com/docs/wash/config/).

**TinyGo**

Use the `wash build` command from the root of a project directory to compile the component into a `.wasm` binary:

shell

```shell
wash build --skip-fetch
```

By default, the compiled `.wasm` binary for a TinyGo project is generated at `/build/`. The output path for the compiled `.wasm` binary [can be configured via `wash`'s configuration file](https://wasmcloud.com/docs/wash/config/).

**TypeScript**

Use the `wash build` command from the root of a project directory to compile the component into a `.wasm` binary:

shell

```shell
wash build
```

By default, the compiled `.wasm` binary for a TypeScript project is generated at `/dist/`. The output path for the compiled `.wasm` binary [can be configured via `wash`'s configuration file](https://wasmcloud.com/docs/wash/config/).

> **Directory context in `wash`**
>
> You can run `wash build` from anywhere inside your project directory. From outside, you can use the `-C` flag to target a project directory. See the [Command Reference](https://wasmcloud.com/docs/wash/commands/) for more information, as well as more options for the `wash build` command.

### Build commands

Wasm Shell executes the build command for your language toolchain specified in the project's [`wash`'s configuration file](https://wasmcloud.com/docs/wash/config/).

For example:

**Rust**

yaml

```yaml
build:
  command: cargo build --target wasm32-wasip2 --release
  component_path: target/wasm32-wasip2/release/output.wasm
```

**TinyGo**

yaml

```yaml
build:
  command: go generate ./... && tinygo build -target wasip2 -wit-package ./wit -wit-world example -o build/output.wasm ./
  component_path: build/output.wasm
```

**TypeScript**

yaml

```yaml
build:
  command: npm run install-and-build
  component_path: dist/output.wasm
```

This configuration is used to build the component when you run `wash dev`, so it must be in place and properly configured for `wash dev` to work.

### Interface dependencies and `wash build`

When you run `wash build`, `wash` reads the specified world in your WIT files and downloads the appropriate dependencies automatically into the `wit/deps` directory. As such, in most cases you should add `wit/deps` to your `.gitignore` file.

Without any additional configuration, `wash` can download dependencies from the following namespaces (i.e. the `wasi` in `wasi:http@0.2.1`):

- `wasi`: Interfaces proposed for the common [WebAssembly System Interface (WASI) standard](https://wasi.dev/)
- `wasmcloud`: Interfaces maintained as part of the wasmCloud project
- `wrpc`: Interfaces maintained as part of the WIT-over-RPC ([wRPC](https://github.com/bytecodealliance/wrpc)) project
- `ba`: Interfaces maintained by the [Bytecode Alliance](https://bytecodealliance.org/)

## Components and OCI registries

Once you're finished iterating on your component, you can publish it to any OCI compliant registry that supports **OCI artifacts**. These artifacts are not container images, but conform to OCI standards and may be stored on any OCI-compatible registry.

### Authenticating to OCI registries

`wash` supports the usage of Docker credentials for authentication to registries. There are multiple [ways to authenticate with Docker credentials](https://docs.docker.com/reference/cli/docker/login/), including the `docker login` command with the `docker` CLI:

shell

```shell
docker login <registry> -u <username> -p <password-or-token>
```

### Publishing to OCI registries

Push the component to your registry:

shell

```shell
wash oci push ghcr.io/<namespace>/hello:0.2.0 ./dist/http-hello-world.wasm
```

- The target registry address (including artifact name and tag) are specified for the first option with `wash oci push`.
- The second option defines the target path for the component binary to push.

Last updated on **Jun 10, 2026** by **Liam Randall**
