#How to properly structure a Rust frontend in Tauri v2

8 messages · Page 1 of 1 (latest)

floral pewter
#

I am migrating from v1 to v2 and thought I would switch from JavaScript to a Rust frontend, specifically Leptos.
But now I don't know how to properly setup my project as I previously simply had the JavaScript files outside kind of wrapping around the src-tauri folder.
I was thinking maybe create a src-ui folder as in this example (https://github.com/michalvavra/tauri-leptos-example/tree/main) or is there a more efficient way?

On that note, how do I now properly interchange data between frontend and backend? Still using the Tauri API?

wheat marsh
#

Mind sharing why did you choose leptos over some js framework?

floral pewter
#

To try something new to be honest. There was nothing wrong with JavaScript, in fact if Leptos doesn't turn out to work that good I will back up to Vite. But I think it would be convenient in the future to have all on the same codebase. Especially for testing and distributing the app

daring island
#

for what it's worth, create-tauri-app --beta has a leptos template. It's similar to the template you linked but kept the src name instead of src-ui (works the same though).

On that note, how do I now properly interchange data between frontend and backend? Still using the Tauri API?
yes. The rust frontend will be compiled to wasm and still runs in the browser's sandbox so we still need the same communication mechanisms as a js frontend.

floral pewter
#

@daring island Sorry, it's a dumb question, but how do I use the invoke() function in Rust? 😅

wheat marsh
#

I think you need js anyway. Rust wasm -> js invoke -> rust tauri but tauri guys can correct me

daring island
#

yeah, pretty much