dioxus/packages/webview/README.md

48 lines
2.2 KiB
Markdown
Raw Normal View History

2021-01-21 08:22:08 +00:00
# Dioxus-webview
2021-06-03 16:02:46 +00:00
Dioxus-webview bridges virtual and Webview DOMs together to make simple, portable, desktop applications.
2021-01-21 08:22:08 +00:00
Dioxus-webview is an attempt at making a simpler "Tauri" where creating desktop applications is as simple as:
```rust
// main.rs
2021-01-21 16:10:31 +00:00
#[async_std::main]
async fn main() {
2021-01-21 08:22:08 +00:00
dioxus_webview::new(|ctx| {
2021-06-03 16:02:46 +00:00
let (count, set_count) = use_state(&ctx, || 0);
2021-01-21 08:22:08 +00:00
html! {
<div>
<h1> "Dioxus Desktop Demo" </h1>
<p> "Count is {count}"</p>
<button onclick=|_| set_count(count + 1) >
"Click to increment"
</button>
</div>
}
})
.configure_webview(|view| {
2021-06-03 16:02:46 +00:00
// custom webview config options
2021-01-21 08:22:08 +00:00
})
2021-01-21 16:10:31 +00:00
.launch()
.await;
2021-01-21 08:22:08 +00:00
}
```
and then to create a native .app:
```
dioxus bundle --platform macOS
```
## Goals
2021-03-16 15:03:59 +00:00
Because the host VirtualDOM is running in its own native process, native applications can unlock their full potential. Dioxus-webview is designed to be a 100% rust alternative to ElectronJS without the memory overhead or bloat of ElectronJS apps.
2021-01-21 08:22:08 +00:00
By bridging the native process, desktop apps can access full multithreading power, peripheral support, hardware access, and native filesystem controls without the hassle of web technologies. Our goal with Dioxus-webview is to make it easy to ship both a web and native application, and quickly see large performance boosts without having to re-write the whole stack. As the dioxus ecosystem grows, we hope to see 3rd parties providing wrappers for storage, offline mode, etc that supports both web and native technologies.
2021-01-21 16:10:31 +00:00
## Tech
Dioxus-desktop is a pure liveview application where all of the state and event handlers are proxied through the liveview and into the native process. For pure server-based liveview, this would normally be too slow (in both render performance and latency), but because the VDom is local, desktop apps are just as fast as Electron.
2021-06-03 16:02:46 +00:00
Dioxus-desktop leverages dioxus-liveview under the hood, but with convenience wrappers around setting up the VDom bridge, proxying events, and serving the initial WebSys-Renderer. The backend is served by Tide, so an async runtime _is_ needed - we recommend async-std in tokio mode.