Templates & Examples
Get started building components for wasmCloud.
- Templates are scaffolds for new applications. Use
wash newto create a project from a template, then customize it for your use case. - Examples are complete applications demonstrating specific wasmCloud capabilities.
All templates and examples on this page target wasmCloud v2 and require wash 2.0.0+; a small number of entries require a newer wash version and call this out inline (for example, WebGPU TensorFlow requires 2.1.0+ because WebGPU in services landed in that release). Components target the WASI 0.2 component model. Interface versions shown reflect what is pinned in each template or example at time of writing; wash new always pulls current source from the repository.
Templates
| Template | Language | Description |
|---|---|---|
| HTTP Hello World | Rust | HTTP server using wstd |
| TCP Service | Rust | HTTP API + TCP service workspace |
| HTTP Client (Rust) | Rust | Outgoing HTTP proxy with wstd::http::Client |
| HTTP Handler (axum) | Rust | Full REST API handler using axum via wstd-axum |
| HTTP Handler with Key-Value Storage (Rust) | Rust | REST API + wasi:keyvalue |
| HTTP API with Distributed Workloads (Rust) | Rust | Two components coordinating via wasmcloud:messaging |
| HTTP Hello World (Hono) | TypeScript | HTTP server using Hono |
| HTTP Hello World (Fetch API) | TypeScript | HTTP server using the Fetch API |
| HTTP Client | TypeScript | Outgoing HTTP proxy |
| HTTP Handler (Hono) | TypeScript | Full REST API handler |
| HTTP Handler with Blob Storage (Hono) | TypeScript | REST API + wasi:blobstore |
| HTTP Handler with Filesystem (Hono) | TypeScript | REST API + wasi:filesystem |
| HTTP Handler with Key-Value Storage (Hono) | TypeScript | REST API + wasi:keyvalue |
| HTTP Handler with Logging (Hono) | TypeScript | REST API + structured logging via wasi:logging |
| HTTP API with Distributed Workloads | TypeScript | Two components coordinating via wasmcloud:messaging |
| TCP Echo Service | TypeScript | HTTP component + TCP service workload |
Rust
Requires the Rust toolchain with the wasm32-wasip2 target. After scaffolding with wash new, run wash dev from the project directory to start the development loop. See Quickstart prerequisites for setup instructions.
HTTP Hello World
A minimal HTTP server component built with the wstd async runtime for Wasm components.
- Source:
wasmCloud/wasmCloud — templates/http-hello-world - Interfaces: Exports
wasi:http/incoming-handler
Create from template:
wash new https://github.com/wasmCloud/wasmCloud.git --name my-project --subfolder templates/http-hello-worldTCP Service
A two-component Rust workspace. http-api is an HTTP server that accepts text input via a web UI and forwards it to service-leet, a TCP server that transforms text to "leet speak" (e.g., hello world → h3110 w0r1d). Together they demonstrate a multi-component service pattern with TCP transport.
- Source:
wasmCloud/wasmCloud — templates/service-tcp http-apiinterfaces: Exportswasi:http/incoming-handler; makes outgoing TCP connectionsservice-leetinterfaces: TCP server (listens on port 7777)
Create from template:
wash new https://github.com/wasmCloud/wasmCloud.git --name my-service --subfolder templates/service-tcpHTTP Client (Rust)
An HTTP proxy component that makes outgoing HTTP requests using wstd::http::Client. Uses the wstd #[http_server] proc macro to handle the incoming request and proxies the call upstream.
- Source:
wasmCloud/wasmCloud — templates/http-client - Interfaces: Imports
wasi:http/outgoing-handler@0.2.2; exportswasi:http/incoming-handler@0.2.2
Create from template:
wash new https://github.com/wasmCloud/wasmCloud.git --name my-project --subfolder templates/http-clientHTTP Handler (axum)
A full-featured HTTP handler component using axum for routing, wired to wasi:http/incoming-handler via wstd-axum. The template demonstrates routing, query parameters, and JSON request and response bodies, with axum's default features (which depend on tokio and hyper) disabled in favor of the Wasm-compatible feature set.
- Source:
wasmCloud/wasmCloud — templates/http-handler - Interfaces: Exports
wasi:http/incoming-handler@0.2.2
Create from template:
wash new https://github.com/wasmCloud/wasmCloud.git --name my-project --subfolder templates/http-handlerHTTP Handler with Key-Value Storage (Rust)
An HTTP handler component that stores and retrieves key-value pairs over HTTP, backed by wasi:keyvalue/store. The component speaks only the WASI interface; the host runtime selects the underlying storage backend (in-memory, filesystem, NATS, Redis, and others) based on .wash/config.yaml, so the same component code runs against any supported backend without modification.
- Source:
wasmCloud/wasmCloud — templates/http-kv-handler - Interfaces: Imports
wasi:keyvalue/store@0.2.0-draft; exportswasi:http/incoming-handler@0.2.2
Create from template:
wash new https://github.com/wasmCloud/wasmCloud.git --name my-project --subfolder templates/http-kv-handlerHTTP API with Distributed Workloads (Rust)
A two-component Rust workspace demonstrating distributed workloads over messaging. An http-api component receives POST /task requests and dispatches work via wasmcloud:messaging/consumer; a task-leet component exports wasmcloud:messaging/handler and transforms the payload (e.g., text → "leet speak"). During wash dev, the runtime routes calls between components in-process — no NATS server required.
- Source:
wasmCloud/wasmCloud — templates/http-api-with-distributed-workloads http-apiinterfaces: Importswasmcloud:messaging/consumer@0.2.0; exportswasi:http/incoming-handler(via thewstd#[http_server]proc macro)task-leetinterfaces: Importswasmcloud:messaging/consumer@0.2.0; exportswasmcloud:messaging/handler@0.2.0
Create from template:
wash new https://github.com/wasmCloud/wasmCloud.git --name my-project --subfolder templates/http-api-with-distributed-workloadsTypeScript
Requires npm v14.17+ and TypeScript v5.6+. After scaffolding with wash new, run npm run dev from the project directory to start the development loop. See Quickstart prerequisites for setup instructions.
TypeScript templates use the @bytecodealliance/jco-std adapter for WASI compatibility and are available in the templates/ directory of wasmCloud/typescript.
HTTP Hello World (Hono)
A minimal HTTP server component using the Hono web framework.
- Source:
wasmCloud/typescript — templates/http-hello-world-hono - Interfaces: Exports
wasi:http/incoming-handler@0.2.6
Create from template:
wash new https://github.com/wasmCloud/typescript.git --name my-project --subfolder templates/http-hello-world-honoHTTP Hello World (Fetch API)
A minimal HTTP server component using the Service Worker Fetch API pattern.
- Source:
wasmCloud/typescript — templates/http-hello-world-fetch - Interfaces: Exports
wasi:http/incoming-handler@0.2.3
Create from template:
wash new https://github.com/wasmCloud/typescript.git --name my-project --subfolder templates/http-hello-world-fetchHTTP Client
An HTTP proxy component that makes outgoing HTTP requests. Supports GET, POST, PUT, DELETE, and PATCH with custom header forwarding, request body handling, JSON parsing, and response header extraction.
- Source:
wasmCloud/typescript — templates/http-client - Interfaces: Imports
wasi:http/outgoing-handler@0.2.3; exportswasi:http/incoming-handler@0.2.3
Create from template:
wash new https://github.com/wasmCloud/typescript.git --name my-project --subfolder templates/http-clientHTTP Handler (Hono)
A full-featured HTTP handler component using Hono, demonstrating middleware patterns including CORS, request logging, response timing, and request ID tracking, with RESTful CRUD endpoints and error handling.
- Source:
wasmCloud/typescript — templates/http-handler-hono - Interfaces: Exports
wasi:http/incoming-handler@0.2.6
Create from template:
wash new https://github.com/wasmCloud/typescript.git --name my-project --subfolder templates/http-handler-honoHTTP Handler with Blob Storage (Hono)
An HTTP handler component using Hono, backed by wasi:blobstore for persistent file storage. Provides a complete REST API for blob CRUD operations.
- Source:
wasmCloud/typescript — templates/http-blobstore-handler-hono - Interfaces: Imports
wasi:blobstore/blobstore@0.2.0-draft; exportswasi:http/incoming-handler@0.2.6
Create from template:
wash new https://github.com/wasmCloud/typescript.git --name my-project --subfolder templates/http-blobstore-handler-honoHTTP Handler with Filesystem (Hono)
An HTTP handler component using Hono that serves files from a mounted directory via wasi:filesystem. Demonstrates reading from a preopened host directory inside a Wasm component.
- Source:
wasmCloud/typescript — templates/http-filesystem-handler-hono - Interfaces: Imports
wasi:filesystem/types@0.2.2,wasi:filesystem/preopens@0.2.2; exportswasi:http/incoming-handler@0.2.6
Create from template:
wash new https://github.com/wasmCloud/typescript.git --name my-project --subfolder templates/http-filesystem-handler-honoHTTP Handler with Key-Value Storage (Hono)
An HTTP handler component using Hono, backed by wasi:keyvalue for persistent key-value storage. Demonstrates CRUD operations, atomic incrementation, and Hono middleware patterns. When run with npm run dev, a NATS-KV key-value provider is automatically configured.
- Source:
wasmCloud/typescript — templates/http-kv-handler-hono - Interfaces: Imports
wasi:keyvalue/store@0.2.0-draft,wasi:keyvalue/atomics@0.2.0-draft; exportswasi:http/incoming-handler@0.2.6
Create from template:
wash new https://github.com/wasmCloud/typescript.git --name my-project --subfolder templates/http-kv-handler-honoHTTP Handler with Logging (Hono)
An HTTP handler component using Hono that emits structured logs via wasi:logging. Every request and response is logged at the appropriate level (trace, debug, info, warn, error, critical) so you can see how WASI logging integrates with the wasmCloud host's structured log output.
- Source:
wasmCloud/typescript — templates/http-logging-handler-hono - Interfaces: Imports
wasi:logging/logging@0.1.0-draft; exportswasi:http/incoming-handler@0.2.6
Create from template:
wash new https://github.com/wasmCloud/typescript.git --name my-project --subfolder templates/http-logging-handler-honoHTTP API with Distributed Workloads
A two-component TypeScript project demonstrating component-to-component coordination over wasmcloud:messaging. An http-api component accepts POST /task requests and dispatches work via wasmcloud:messaging/consumer; a task-worker component exports wasmcloud:messaging/handler, processes the payload, and returns a reply. During wash dev, the runtime routes calls between components in-process — no NATS server required.
- Source:
wasmCloud/typescript — templates/http-api-with-distributed-workloads http-apiinterfaces: Importswasmcloud:messaging/consumer@0.2.0; exportswasi:http/incoming-handler@0.2.6task-workerinterfaces: Importswasmcloud:messaging/consumer@0.2.0; exportswasmcloud:messaging/handler@0.2.0
Create from template:
wash new https://github.com/wasmCloud/typescript.git --name my-project --subfolder templates/http-api-with-distributed-workloadsTCP Echo Service
A two-workload TypeScript project demonstrating the wasmCloud service model. A TCP service workload accepts connections on 127.0.0.1:7878, reads lines, and replies with the word count. A component workload exposes POST /count, forwards text to the TCP service over the in-process loopback network, and returns a JSON response.
- Source:
wasmCloud/typescript — templates/service-tcp-echo serviceinterfaces: Importswasi:sockets/tcp@0.2.3(and related socket interfaces); exportswasi:cli/run@0.2.0componentinterfaces: Importswasi:sockets/tcp@0.2.3(and related socket interfaces); exportswasi:http/incoming-handler@0.2.6
Create from template:
wash new https://github.com/wasmCloud/typescript.git --name my-project --subfolder templates/service-tcp-echoExamples
Complete example applications are available in the examples/ directory of wasmCloud/wasmCloud (Rust) and the examples/components/ directory of wasmCloud/typescript (TypeScript). Run wash dev from any example directory to build and start a local development environment.
| Example | Language | OCI Artifact |
|---|---|---|
| Blobby | Rust | ghcr.io/wasmcloud/components/blobby |
| gRPC Hello World | Rust | components/grpc-hello-world-client, components/grpc-hello-world-server |
| OpenTelemetry HTTP Counter | Rust | ghcr.io/wasmcloud/components/otel-http |
| QR Code Generator | Rust | ghcr.io/wasmcloud/components/qrcode |
| HTTP Axios | TypeScript | — |
| HTTP Password Checker | TypeScript | — |
| HTTP Server with Hono | TypeScript | — |
| HTTP stdio | TypeScript | — |
| HTTP Streaming | TypeScript | — |
| WebGPU TensorFlow | TypeScript | — |
| WASI Config from Kubernetes Env | TypeScript | — |
Rust
Blobby
A file server component ("Little Blobby Tables") demonstrating CRUD operations on blob storage, served through a web UI. Built with the wstd async runtime.
- Source:
wasmCloud/wasmCloud — examples/blobby - OCI artifact:
ghcr.io/wasmcloud/components/blobby - Interfaces: Imports
wasi:blobstore/blobstore@0.2.0-draft; exportswasi:http/incoming-handler(via thewstd#[http_server]proc macro)
gRPC Hello World
Two components demonstrating how to make and serve gRPC calls from a wasmCloud component. component-client calls an external gRPC server; component-server serves gRPC traffic to an external client. Built with tonic and prost over HTTP/2.
- Source:
wasmCloud/wasmCloud — examples/grpc-hello-world - OCI artifacts:
ghcr.io/wasmcloud/components/grpc-hello-world-client,ghcr.io/wasmcloud/components/grpc-hello-world-server component-clientinterfaces: Importswasi:http/outgoing-handler; exportswasi:http/incoming-handler(viawstd)component-serverinterfaces: Exportswasi:http/incoming-handler(viawstd)
OpenTelemetry HTTP Counter
An HTTP counter service instrumented with OpenTelemetry through the wasi:otel interfaces. Each request creates a parent server span, emits child spans for downstream HTTP / blobstore / keyvalue operations, records structured log entries correlated with the active trace, and exports request-count and response-size metrics.
- Source:
wasmCloud/wasmCloud — examples/otel-http - OCI artifact:
ghcr.io/wasmcloud/components/otel-http - Interfaces: Imports
wasi:otel/{tracing,logs,metrics,types}@0.2.0-rc.1,wasi:http/outgoing-handler@0.2.2,wasi:blobstore/{blobstore,container}@0.2.0-draft,wasi:keyvalue/{store,atomics}@0.2.0-draft,wasi:config/store@0.2.0-rc.1,wasi:clocks/wall-clock@0.2.0,wasi:logging/logging@0.1.0-draft; exportswasi:http/incoming-handler@0.2.2
QR Code Generator
A QR code generator that accepts text input via HTTP and returns a PNG-encoded QR code, with a web UI.
- Source:
wasmCloud/wasmCloud — examples/qrcode - OCI artifact:
ghcr.io/wasmcloud/components/qrcode - Interfaces: Exports
wasi:http/incoming-handler@0.2.2
TypeScript
HTTP Axios
A CLI-style component that uses axios to perform an outbound HTTP request and returns the result through a custom WIT interface. The same component can be invoked via wash call, wasmtime run, or jco run through its wasi:cli/run entrypoint. Demonstrates pulling in a widely-used npm package and using it inside a component.
- Source:
wasmCloud/typescript — examples/components/http-axios - Interfaces: Exports
wasi:cli/run@0.2.3and a customwasmcloud:examples/invokeinterface
HTTP Password Checker
A wasi:http-compliant HTTP handler that provides an API for checking password strength. Uses only standard WASI interfaces (no wasmCloud-specific dependencies) and demonstrates pulling in JS ecosystem packages inside a component — notably valibot for schema validation and check-password-strength for the strength heuristic.
- Source:
wasmCloud/typescript — examples/components/http-password-checker - Interfaces: Exports
wasi:http/incoming-handler@0.2.2
HTTP Server with Hono
An HTTP server component built on Hono via a custom adapter that bridges Hono onto the wasi:http/incoming-handler interface. Includes example routes (/api/data, /api/config) and demonstrates a minimal Hono + wasi:http setup.
- Source:
wasmCloud/typescript — examples/components/http-server-with-hono - Interfaces: Exports
wasi:http/incoming-handler@0.2.3
HTTP stdio
A small HTTP handler that demonstrates writing to stdout and stderr from inside a component via the wasi:cli stream interfaces. Responds to GET /?name=<name> while logging the request to the host's stdout/stderr.
- Source:
wasmCloud/typescript — examples/components/http-stdio - Interfaces: Imports
wasi:cli/stdout@0.2.6,wasi:cli/stderr@0.2.6; exportswasi:http/incoming-handler@0.2.6
HTTP Streaming
An HTTP component that performs a streaming response using wasi:http and wasi:io primitives, streaming 1 MiB of random bytes on every request. Demonstrates how to stream a response body from a TypeScript component without buffering.
- Source:
wasmCloud/typescript — examples/components/http-streaming - Interfaces: Imports
wasi:random/random@0.2.3; exportswasi:http/incoming-handler@0.2.3
WebGPU TensorFlow
A two-workload TypeScript example demonstrating GPU-accelerated machine learning inside a wasmCloud workload, running TensorFlow.js with the WebGPU backend on top of wasi:webgpu. A service workload loads a style-transfer model into GPU memory at startup and serves a binary protocol on loopback TCP 127.0.0.1:7878; a component workload serves the browser UI and forwards POST /stylize requests to the service, returning the stylized JPEG.
- Source:
wasmCloud/typescript — examples/components/webgpu-tensorflow serviceinterfaces: Importswasi:webgpu/webgpu@0.0.1,wasi:graphics-context/graphics-context@0.0.1,wasi:sockets/tcp@0.2.3(and related socket interfaces); exportswasi:cli/run@0.2.3componentinterfaces: Importswasi:sockets/tcp@0.2.3(and related socket interfaces); exportswasi:http/incoming-handler@0.2.3- Requirements:
wash≥ 2.1.0 (WebGPU in services landed in 2.1.0) and a GPU on the host machine runningwash dev
WASI Config from Kubernetes Env
An HTTP component that reads runtime configuration via the wasi:config/store interface, demonstrating how wasmCloud sources config from Kubernetes ConfigMaps and Secrets at runtime. Exposes GET /config (all values as JSON) and GET /config/:key (a single value). The component contains no Kubernetes-specific code — values are injected by the wasmCloud config provider, which can be backed by a ConfigMap or Secret in a Kubernetes deployment.
- Source:
wasmCloud/typescript — examples/components/wasi-config-from-k8s-env - Interfaces: Imports
wasi:config/store@0.2.0-rc.1; exportswasi:http/incoming-handler@0.2.6