leptos-rs / start-axum

Starter template for use with the Leptos web framework and Axum.
The Unlicense
141 stars 26 forks source link

start-axum Template Project Not Working as Expected #32

Closed jlvihv closed 8 months ago

jlvihv commented 8 months ago

Issue Description

I am experiencing difficulties with the start-axum project template when creating a new project using it as a template. Upon running the project with the command cargo run --features ssr, the expected behavior is that the project should function properly. Specifically, when clicking the "Click Me" button, the counter should increment by 1. However, the counter does not respond as expected.

Reproduction Steps

Create a new project using the start-axum project template. Run the project using the command: cargo run --features ssr. Open the project in a web browser. Click the "Click Me" button and observe the counter behavior.

Expected Behavior

The counter should increment by 1 when the "Click Me" button is pressed. The project should display the necessary files (js, css, wasm) without any 404 errors.

Actual Behavior

The counter does not respond as expected. Browser console shows 404 errors for js, css, and wasm files.

gbj commented 8 months ago

The behavior you are expected is not the way it works.

When you are using a Rust framework that compiles code to WebAssembly for interactivity in the frontend, it requires building both the native binary (which you're doing with cargo run --features=ssr) and compiling the frontend to WebAssembly for interactivity in the browser (which you're not doing, hence the lack of interactivity and the 404 errors for JS and WASM.)

You can build these two halves manually using wasm-pack and then cargo run. Or, you can use the cargo-leptos build tool, which coordinates rebuilding these two halves for you, as is described in the README and in the docs.

jlvihv commented 8 months ago

I sincerely apologize. I forgot to carefully read the README. After using cargo leptos watch to run the project and installing wasm32-unknown-unknown, the project ran successfully. I appreciate your patient assistance.