#how does tauri work

11 messages · Page 1 of 1 (latest)

lilac nimbus
#

hello, new here and im also new to rust and programming in general, is there anyone who could explain how tauri works? what's the difference between the tauri frontend and tauri backend? are they two seperate os processes, maybe threads? is the tauri backend running a specific tauri runtime, or can i run it on other runtimes like tokio? should the tauri frontend or tauri backend communicate with a web server? etc..
many questions i know, my first questions are the most important for me

cyan wharf
#

Hello, I second those questions! When browsing the official documentation, I was looking for some guidance on what to build in the front-end and what to build in the back-end. I initially wanted to leverage the many advantages of Rust and do most of the work there, using Next.js for the presentation layer only, but then I saw that the official SQL plugin is designed to be used from the front-end. I reached the conclusion that most developers using Tauri are probably are more comfortable with JavaScript/TypeScript, coming from something like Electron perhaps, and so favour doing most of the work in the “front-end”. Either way, that seems like a great way to bootstrap, then later move more logic to Rust, as the application matures.

unreal stirrup
#

You can read more detail at https://tauri.app/v1/references/architecture/ and it's sub-pages.

what's the difference between the tauri frontend and tauri backend? are they two seperate os processes, maybe threads?
Yes, they are separate processes. Tauri runs many threads within the back-end. The front-end's internal workings are up to the webview shipped by the OS vendor but is usually multiple processes running multiple threads.
is the tauri backend running a specific tauri runtime, or can i run it on other runtimes like tokio?
Tauri uses Tokio so there shouldn't be any issue with you using it as well.
should the tauri frontend or tauri backend communicate with a web server?
The official recommendation is to use static files which are bundled at build time. Tauri allows communication with a web server but considers it a security risk for release builds due to the powerful nature of the API. The dev builds can be configured to serve files from a web server for developer convenience, such as with hot reloading.

muted cloud
#

about frontend vs rust-side:
Basically our recommendation is always that rust should host as most business logic etc as possible, but we also recognize that the majority of tauri users aren't exactly fluent in rust, and may not have ever seen a single line of rust code, and may not even want to write it ever. So that's where for example the sql plugin comes in. sql in the frontend is def not recommended, but for many people there isn't really an alternative.

lilac nimbus
unreal stirrup
lilac nimbus
#

why would i serve html pages from the web server if im using tauri?

#

but okay i see the confusion, having a web server is just fine.. my question was if the tauri frontend or the backend should be connecting to the web server

#

with fabians response, i can see that it should be done in the backend