---
title: "Components | wasmCloud"
description: "How to develop WebAssembly components with Rust"
canonical: "https://wasmcloud.com/docs/v1/developer/languages/rust/components/"
---

This is documentation for wasmCloud **v1**, which is no longer actively maintained.

For up-to-date documentation, see the **[latest version](https://wasmcloud.com/docs/)** (v2).

Version: v1

# Building components with Rust

The [Rust](https://rust-lang.org) ecosystem has excellent support for building WebAssembly components.

Starting with the `wasm32-unknown-unknown` target used in the past for bare WebAssembly modules, extending to the [`wasm32-wasip2`](https://doc.rust-lang.org/stable/rustc/platform-support/wasm32-wasip2.html) (which reached [Tier 2 support in 2024](https://blog.rust-lang.org/2024/11/26/wasip2-tier-2.html)) which has the latest and greatest of the component model, Rust has done much to keep up with and help grow the WebAssembly ecosystem.

The main [`wasmCloud/wasmCloud`](https://github.com/wasmCloud/wasmcloud/tree/main) repository contains Rust exmaples directly in-tree, with examples of components and providers listed there.

## Rust's standard toolchain is WebAssembly-ready

Standard Rust tooling can be used with Rust's WebAssembly support. Often the only thing needed to be able to build a Rust webassembly project is an added target (e.g. `wasm32-wasip1`, `wasm32-wasip2`), or a properly formatted `rust-toolchain.toml` file in the project folder.

To install the `wasm32-wasip1` or `wasm32-wasip2` targets, you can use [`rustup`](https://rust-lang.github.io/rustup):

console

```console
rustup target add wasm32-wasip2
```

Once tools are installed, components can be built with [`cargo`](https://doc.rust-lang.org/cargo):

```
cargo build --target=wasm32-wasip2
```

> **Tip**
>
> [The wasmCloud Shell (`wash`)](https://wasmcloud.com/docs/v1/ecosystem/wash/) is the easiest way to build wasmCloud projects

## Get started

In this walkthrough, we will create an compoennt that responds to HTTP requests using Rust.

This walkthrough requires:

- [cargo](https://doc.rust-lang.org/cargo)
- [wasmCloud Shell (`wash`)](https://wasmcloud.com/docs/v1/installation/) CLI 0.36.1+ for building and deploying components

### Step 1: Build a project with `wash`

The wasmCloud Shell (`wash`) CLI helps developers build component-based applications that can be deployed with wasmCloud, bundling and re-using language-specific tooling to build wasmCLoud projects.

We can use `wash new` to scaffold out a new Rust project:

console

```console
wash new component http-test --template-name hello-world-rust
```

This will create a `http-test` folder which we can `cd` into:

console

```console
cd http-test
```

We can then immediately run `wash build` to build our project as a WebAssembly component:

console

```console
wash build
```

> **Tip**
>
> Similar to other Rust projects, WebAssembly binaries are placed in `target` after being built.
>
> To reduce inconsistencies across langauges `wash` consistently places built artifacts in the `build` folder of a given wasmCloud project.

The `wash inspect` subcommand enables us to examine the new component's imports and exports:

console

```console
wash inspect --wit build/http_hello_world_s.wasm
```

You should see output that looks like the following:

wit

```wit
package root:component;

world root {
  import wasi:io/poll@0.2.2;
  import wasi:clocks/wall-clock@0.2.2;
  import wasi:random/random@0.2.2;
  import wasi:io/error@0.2.2;
  import wasi:io/streams@0.2.2;
  import wasi:cli/stdout@0.2.2;
  import wasi:cli/stderr@0.2.2;
  import wasi:cli/stdin@0.2.2;
  import wasi:http/types@0.2.2;
  import wasi:cli/environment@0.2.2;
  import wasi:cli/exit@0.2.2;
  import wasi:filesystem/types@0.2.2;
  import wasi:filesystem/preopens@0.2.2;

  export wasi:http/incoming-handler@0.2.2;
}
```

Once our component is built, we can start a local developer loop to use our app locally:

console

```console
wash dev
```

While `wash dev` won't return, it will have started a HTTP server that you can send requests to.

> **Tip**
>
> `wash dev` is able to start up a HTTP server automatically because it discovers your application's dependencies via WIT.

After a second or two, in another console/tab, we can `curl` the application that was deployed locally:

```
$ curl localhost:8000
Hello from Rust!
```

## Next steps

- Explore [capabilities](https://wasmcloud.com/docs/v1/capabilities/) you can use in your wasmCloud application.
- Learn [how to build a capability provider in Rust](https://wasmcloud.com/docs/v1/developer/languages/rust/providers/).

Last updated on **Nov 20, 2026** by **Victor Adossi**
