TL;DR: See sergey-melnychuk/project-one.

At the time of writing this post Cloudflare Workers says:

Deploy serverless code instantly across the globe to give it exceptional performance, reliability, and scale.

Basically looks like an AWS Lambda but with benfits of WASM runtime (scalability, performance, no “cold starts”, no network overhead).


Install wrangler and follow Project One (note that dependency versions are likely to be outdated):


name = "project-one"
version = "0.1.0"
edition = "2021"

crate-type = ["cdylib", "rlib"]

wasm-bindgen = "0.2"
worker = "0.0.11"


name = "project-one"
compatibility_date = "2022-10-10"

main = "build/worker/shim.mjs"

command = "worker-build --release"


use worker::*;

pub async fn main(_req: Request, _env: Env, _ctx: Context) -> Result<Response> {
    // TODO: do your thing


cargo install worker-build
worker-build --release

Run locally (development mode)

$ wrangler dev
 ⛅️ wrangler 3.0.0
wrangler dev now uses local mode by default, powered by 🔥 Miniflare and 👷 workerd.
To run an edge preview session for your Worker, use wrangler dev --remote
Running custom build: worker-build --release
[INFO]: 🎯  Checking for the Wasm target...
[INFO]: 🌀  Compiling to Wasm...
    Finished release [optimized] target(s) in 0.06s
[INFO]: ⬇️  Installing wasm-bindgen...
[INFO]: Optimizing wasm binaries with `wasm-opt`...
[INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended
[INFO]: ✨   Done in 2.43s
[INFO]: 📦   Your wasm pkg is ready to publish at /home/work/Temp/project-one/build.

  shim.mjs  11.8kb

⚡ Done in 5ms
⎔ Starting local server...
[mf:inf] Ready on

NOTE: Running on Ubuntu 22.04 needs sudo apt install libc++1. More details here.

Deploy to Cloudflare

# export CLOUDFLARE_API_TOKEN=<snip>
wrangler publish

After publishing, you get a public URL to trigger the worker.