Skip to content

Upgrade leptos_ssr_axum example to latest leptos_wasi and WASIp3#3

Merged
codeitlikemiley merged 2 commits into
mainfrom
upgrade-leptos-wasi-wasip3
May 29, 2026
Merged

Upgrade leptos_ssr_axum example to latest leptos_wasi and WASIp3#3
codeitlikemiley merged 2 commits into
mainfrom
upgrade-leptos-wasi-wasip3

Conversation

@codeitlikemiley
Copy link
Copy Markdown
Owner

This PR updates the leptos_ssr_axum example in examples/leptos_ssr_axum to align with the latest leptos_wasi changes, switching to the WASIp3 http trigger standard.

Changes Made

1. Updated Cargo.toml

  • Set edition = "2024" and rust-version = "1.93.0".
  • Set build = "build.rs".
  • Added dependencies: bytes, futures, hydration_context, server_fn, wasip3, http, and http-body.
  • Updated leptos_wasi to point to the official repository at revision 216acc484b0d6fe4b18876f1c96b68272498592b.
  • Updated spin-sdk to version 6.0.0 with json feature.
  • Configured client/server wasm-release profiles and targets (wasm32-wasip2).

2. Configured spin.toml

  • Set executor = { type = "http" } for trigger.
  • Changed component source to target target/wasm32-wasip2/release/leptos_ssr_axum.wasm instead of wasm32-wasip1.
  • Configured build commands using WASI_RUNTIME=spin.

3. Added build.rs

  • Created a standard build script that propagates WASI_RUNTIME environment variable into standard runtime_spin/runtime_wasmtime compiler flags.

4. Code Migration & Refactoring

  • src/server.rs:
    • Migrated the incoming handler from the old WASIp1 Guest implementation to the latest wasip3::exports::http::handler::Guest pattern.
    • Initialized host async task scheduling using init_wasip3_spawner().
    • Converted WASIp3 Request to http::Request using wasip3::http_compat::http_from_wasi_request.
    • Configured Handler built natively using Handler::build(req).await and bound server functions.
    • Implemented serve_static_files to serve static assets from the root.
  • src/app.rs:
    • Updated calls to spin_sdk::key_value::Store (e.g. open_default(), get_json(), set_json(), delete()) to be .awaited, as they are now asynchronous in Spin SDK v6.0.0.
    • Replaced direct spin_sdk::variables::get("agent_server_url") inside component functions with context-based routing (use_context::<AgentServerUrl>()) to facilitate isomorphic SSR/client operations.
    • Added warning-free silence blocks (let _ = id; let _ = call_id;) inside ToolCallView to eliminate compile-time warnings while preserving auto-generated component properties.

@codeitlikemiley codeitlikemiley merged commit 8ede7c5 into main May 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant