jetli / rust-yew-realworld-example-app

Exemplary real world app built with Rust + Yew + WebAssembly, by Function Components + Hooks, also supports desktop by Tauri.
https://jetli.github.io/rust-yew-realworld-example-app/
Apache License 2.0
862 stars 112 forks source link

wasm bindings so Yew can call Tauri Commands? #38

Closed evbo closed 2 years ago

evbo commented 2 years ago

It would be interesting to see the Yew application handle calling the Tauri js API and receiving results from the backend via Tauri Commands.

For many desktop applications this is the only reason Tauri isn't currently suitable for WASM yet and since there are so many needs for backend code (e.g. connecting to sqlite database, filesystem processing, secure communication) this becomes the determining factor against using wasm in Tauri.

...or can this be proven wrong?!

evbo commented 2 years ago

actually it could work just like it has been shown here I think! https://dev.to/stevepryde/create-a-desktop-app-in-rust-using-tauri-and-yew-2bhe

jetli commented 2 years ago

please check this template repo: https://github.com/jetli/rust-yew-axum-tauri-desktop it wraps Yew/Tauri/Axum all together for desktop dev.

evbo commented 2 years ago

Thanks, if I understand correctly you're using a webserver in the Tauri backend rather than using the built-in RPC. I'm not sure of the security or performance considerations for doing so, but that's an interesting alternate path forward!

jetli commented 2 years ago

if you want to call tauri command, here's demo in that repo: https://github.com/jetli/rust-yew-axum-tauri-desktop/blob/9fd99e0ae3aace47c1e634c4b0c07275182b628e/crates/frontend/src/main.rs#L146, gets the port of backend server on startup. and yes, localhost server sure is a security concern one should consider, but it's an easy way to use restful apis and json for Yew.

evbo commented 2 years ago

Thanks and this pretty much sums up all the paths forward so I'll close