From an app to a Worker
Five steps. The first is done once per Soli version; the others are your everyday loop.
-
Build the edge runtime
In the Soli source tree. It needs the wasm32 target and the wasm-bindgen CLI at the version
edge/Cargo.tomlpins; the script says which if they are missing.rustup target add wasm32-unknown-unknown cargo install wasm-bindgen-cli --version 0.2.126 --locked ./scripts/build-edge.sh # → target/edge -
Package your app
From the app folder.
app/,config/andlib/go into the Worker;public/becomes its static assets;.envstays out.export SOLI_EDGE_RUNTIME=~/soli/target/edge soli edge build # → dist/edgedist/edgeis a plain Wrangler project. Itswrangler.tomlis written once; later builds keep your edits. -
Run it on workerd
cd dist/edge npx wrangler dev # http://localhost:8787That is Cloudflare's own runtime, locally: what works here works deployed.
-
Configure it
Everything your app reads with
getenv()comes from the Worker's bindings: plain values under[vars]inwrangler.toml, secrets with Wrangler.[vars] SOLIDB_HOST = "https://db.example.com" SOLIDB_DATABASE = "my_app" SOLIDB_USERNAME = "app"npx wrangler secret put SOLIDB_PASSWORDThe app can tell where it runs:
getenv("SOLI_RUNTIME")is"cloudflare-workers"there. -
Deploy
npx wrangler deployFor your own domain, once its zone is on the same Cloudflare account, add to
wrangler.toml:routes = [{ pattern = "app.example.com", custom_domain = true }]