DioxusLabs / DioxusLabs/dioxus

CSR and Full Stack

Open
#5,468 0 comments 5 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

Hi everyone! I'm trying to build a decoupled fullstack app sharing code between frontend and backend, but deployed separately:

Frontend: Pure CSR static files on Cloudflare Pages.

Backend: API/Server Functions on AWS ECS.

I adapted examples/07-fullstack/desktop for the web. When I build the frontend (dx bundle --web --release) and serve it statically (bunx serve .), it crashes in the browser:

Uncaught InvalidCharacterError: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.

It's looking for window.initial_dioxus_hydration_data (SSR), but I'm serving a static HTML file so it evaluates to undefined.

Cargo.toml

```
[dependencies]
dioxus = { workspace = true, features = ["fullstack"] }
serde = { workspace = true }

[features]
server = ["dioxus/server"]
web = ["dioxus/web"]
```

main.rs
```
use dioxus::prelude::*;

fn main() {
#[cfg(not(feature = "server"))]
dioxus::fullstack::set_server_url("http://127.0.0.1:8080");
dioxus::launch(app);
}

pub fn app() -> Element {
let mut text = use_signal(|| "...".to_string());
rsx! {
button {
onclick: move |_| async move {
if let Ok(data) = get_server_data().await { text.set(data); }
},
"Run server function"
}
}
}

#[get("/api/data")]
async fn get_server_data() -> ServerFnResult {
Ok("Hello!".to_string())
}
```

**Question:**
How do I configure the Dioxus CLI to build a pure CSR client that doesn't expect SSR hydration data, while keeping the fullstack feature enabled so #[server] macros and client fetches still work? Any guidance would be hugely appreciated!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.