Soli at the edge

From an app to a Worker

Five steps. The first is done once per Soli version; the others are your everyday loop.

  1. Build the edge runtime

    In the Soli source tree. It needs the wasm32 target and the wasm-bindgen CLI at the version edge/Cargo.toml pins; 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
  2. Package your app

    From the app folder. app/, config/ and lib/ go into the Worker; public/ becomes its static assets; .env stays out.

    export SOLI_EDGE_RUNTIME=~/soli/target/edge
    soli edge build                  # → dist/edge

    dist/edge is a plain Wrangler project. Its wrangler.toml is written once; later builds keep your edits.

  3. Run it on workerd

    cd dist/edge
    npx wrangler dev                 # http://localhost:8787

    That is Cloudflare's own runtime, locally: what works here works deployed.

  4. Configure it

    Everything your app reads with getenv() comes from the Worker's bindings: plain values under [vars] in wrangler.toml, secrets with Wrangler.

    [vars]
    SOLIDB_HOST = "https://db.example.com"
    SOLIDB_DATABASE = "my_app"
    SOLIDB_USERNAME = "app"
    npx wrangler secret put SOLIDB_PASSWORD

    The app can tell where it runs: getenv("SOLI_RUNTIME") is "cloudflare-workers" there.

  5. Deploy

    npx wrangler deploy

    For your own domain, once its zone is on the same Cloudflare account, add to wrangler.toml:

    routes = [{ pattern = "app.example.com", custom_domain = true }]