mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-25 05:30:21 +00:00
New readme for 0.5! (#2141)
* feature: add new top-level readme.md, highlighting features and a new vs section
This commit is contained in:
parent
fb396b0448
commit
9888d365dd
9 changed files with 288 additions and 45 deletions
293
README.md
293
README.md
|
@ -1,7 +1,12 @@
|
|||
<p align="center">
|
||||
<img src="./notes/header.svg">
|
||||
<p>
|
||||
<a href="https://dioxuslabs.com">
|
||||
<p align="center" >
|
||||
<img src="./notes/header-light.svg#gh-light-mode-only" >
|
||||
<img src="./notes/header-dark.svg#gh-dark-mode-only" >
|
||||
<img src="./notes/dioxus_splash_8.avif">
|
||||
</p>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<div align="center">
|
||||
<!-- Crates version -->
|
||||
<a href="https://crates.io/crates/dioxus">
|
||||
|
@ -51,13 +56,10 @@
|
|||
<a href="https://github.com/DioxusLabs/dioxus/blob/main/translations/tr-tr"> Türkçe </a>
|
||||
</h3>
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<br/>
|
||||
|
||||
> [!WARNING]
|
||||
> Dioxus 0.5 (currently in master) contains massive breaking changes and is not compatible with Dioxus 0.4
|
||||
|
||||
Dioxus is a portable, performant, and ergonomic framework for building cross-platform user interfaces in Rust.
|
||||
Build for web, desktop, and mobile, and more with a single codebase. Zero-config setup, integrated hotreloading, and signals-based state management. Add backend functionality with Server Functions and bundle with our CLI.
|
||||
|
||||
```rust
|
||||
fn app() -> Element {
|
||||
|
@ -71,24 +73,68 @@ fn app() -> Element {
|
|||
}
|
||||
```
|
||||
|
||||
Dioxus can be used to deliver webapps, desktop apps, static sites, mobile apps, TUI apps, liveview apps, and more. Dioxus is entirely renderer agnostic and can be used as a platform for any renderer.
|
||||
|
||||
If you know React, then you already know Dioxus.
|
||||
## ⭐️ Unique features:
|
||||
- Cross-platform apps in three lines of code (web, desktop, mobile, server, and more)
|
||||
- [Ergonomic state management](https://dioxuslabs.com/blog/release-050) combines the best of React, Solid, and Svelte
|
||||
- Extremely performant, powered by Rust's fastest wasm-framework [sledgehammer](https://dioxuslabs.com/blog/templates-diffing)
|
||||
- Integrated bundler for deploying to the web, macOS, Linux, and Windows
|
||||
- And more! Read the [take a tour of Dioxus](https://dioxuslabs.com/learn/0.5/).
|
||||
|
||||
## Unique features:
|
||||
- Desktop apps running natively (no Electron!) in less than 10 lines of code.
|
||||
- Incredibly ergonomic and powerful state management.
|
||||
- Comprehensive inline documentation - hover and guides for all HTML elements, listeners, and events.
|
||||
- Blazingly fast 🔥🔥 and extremely memory efficient
|
||||
- Integrated hot reloading for fast iteration
|
||||
- First-class async support with coroutines and suspense
|
||||
- And more! Read the [full release post](https://dioxuslabs.com/blog/introducing-dioxus/).
|
||||
## Instant hot-reloading
|
||||
With one command, `dx serve` and your app is running. Edit your markup and styles and see the results in real time. Rust code hotreloading is not yet 1st class, but possible with [hot-lib-reloader](https://docs.rs/hot-lib-reloader/latest/hot_lib_reloader/).
|
||||
|
||||
<div align="center">
|
||||
<img src="./notes/hotreload.gif">
|
||||
</div>
|
||||
|
||||
## Bundler for deploying to the web and desktop
|
||||
|
||||
Simply run `dx bundle` and your app will be built and bundled with maximization optimizations. On the web, take advantage of [`.avif` generation, `.wasm` compression, minification](https://dioxuslabs.com/learn/0.5/reference/assets), and more. Build webapps weighing [less than 50kb](https://github.com/ealmloff/tiny-dioxus/) and desktop/mobile apps less than 15mb.
|
||||
|
||||
<div align="center">
|
||||
<img src="./notes/bundle.gif">
|
||||
</div>
|
||||
|
||||
|
||||
## Fantastic documentation
|
||||
|
||||
We've put a ton of effort into building clean, readable, and comprehensive documentation. All html elements and listeners are documented with MDN docs, and our docsite runs continuous integration with Dioxus itself to ensure that the docs are always up to date. Check out the [Dioxus website](https://dioxuslabs.com/learn/0.5/) for guides, references, recipes, and more. Fun fact: we use the Dioxus website as a testbed for new diouxs features - [check it out!](https://github.com/dioxusLabs/docsite)
|
||||
|
||||
<div align="center">
|
||||
<img src="./notes/docs.avif">
|
||||
</div>
|
||||
|
||||
## Emphasis on developer experience
|
||||
|
||||
Dioxus prioritizes developer experience, and we've put a ton of effort into end-to-end tooling. We've built a [VSCode extension](https://marketplace.visualstudio.com/items?itemName=DioxusLabs.dioxus) that autoformats your RSX code, converts HTML to RSX, and more. We've also built a very powerful [CLI](https://github.com/DioxusLabs/cli) that supports creating new apps, serving them, and cross-platform bundling, with deployment on the roadmap.
|
||||
|
||||
<div align="center">
|
||||
<img src="./notes/autofmt.gif">
|
||||
</div>
|
||||
|
||||
## Community
|
||||
|
||||
Dioxus is a community-driven project, with a very active [Discord](https://discord.gg/XgGxMSkvUM) and [GitHub](https://github.com/DioxusLabs/dioxus/issues) community. We're always looking for help, and we're happy to answer questions and help you get started. [Our SDK](https://github.com/DioxusLabs/dioxus-std) is community-run and we even have a [GitHub organization](https://github.com/dioxus-community/) for the best Dioxus crates that receive free upgrades and support.
|
||||
|
||||
<div align="center">
|
||||
<img src="./notes/dioxus-community.avif">
|
||||
</div>
|
||||
|
||||
|
||||
## Full-time core team
|
||||
|
||||
Dioxus has grown from a side project to a small team of fulltime engineers. Thanks to the generous support of FutureWei, Satellite.im, the GitHub Accelerator program, and several amazing individuals, we're able to work on Dioxus full-time. Our long term goal is for Dioxus to become self-sustaining by providing paid high-quality enterprise tools. If your company is interested in adopting Dioxus and would like to work with us, please reach out!
|
||||
|
||||
## Supported Platforms
|
||||
<div align="center">
|
||||
<table style="width:100%">
|
||||
<tr>
|
||||
<td><em>Web</em></td>
|
||||
<td>
|
||||
<b>Web</b>
|
||||
<br />
|
||||
<em>Tier 1 Support</em>
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>Render directly to the DOM using WebAssembly</li>
|
||||
|
@ -99,7 +145,11 @@ If you know React, then you already know Dioxus.
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><em>Desktop</em></td>
|
||||
<td>
|
||||
<b>Desktop</b>
|
||||
<br />
|
||||
<em>Tier 1 Support</em>
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>Render using Webview or - experimentally - with WGPU or Skia </li>
|
||||
|
@ -110,17 +160,11 @@ If you know React, then you already know Dioxus.
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><em>Mobile</em></td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>Render using Webview or - experimentally - with WGPU or Skia </li>
|
||||
<li>Support for iOS and Android </li>
|
||||
<li><em>Significantly</em> more performant than React Native </li>
|
||||
</ul>
|
||||
<b>Liveview</b>
|
||||
<br />
|
||||
<em>Tier 1 Support</em>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><em>Liveview</em></td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>Render apps - or just a single component - entirely on the server</li>
|
||||
|
@ -130,7 +174,25 @@ If you know React, then you already know Dioxus.
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><em>Terminal</em></td>
|
||||
<td>
|
||||
<b>Mobile</b>
|
||||
<br />
|
||||
<em>Tier 2 Support</em>
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>Render using Webview or - experimentally - with WGPU or Skia </li>
|
||||
<li>Support for iOS and Android </li>
|
||||
<li><em>Significantly</em> more performant than React Native </li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<b>Terminal</b>
|
||||
<br />
|
||||
<em>Tier 2 Support</em>
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>Render apps directly into your terminal, similar to <a href="https://github.com/vadimdemedes/ink"> ink.js</a></li>
|
||||
|
@ -142,25 +204,166 @@ If you know React, then you already know Dioxus.
|
|||
</table>
|
||||
</div>
|
||||
|
||||
## Why Dioxus?
|
||||
There's tons of options for building apps, so why would you choose Dioxus?
|
||||
## Dioxus vs other frameworks
|
||||
|
||||
Well, first and foremost, Dioxus prioritizes developer experience. This is reflected in a variety of features unique to Dioxus:
|
||||
We love all frameworks and enjoy watching innovation in the Rust ecosystem. In fact, many of our projects are shared with other frameworks. For example, our flex-box library [Taffy](https://github.com/DioxusLabs/taffy) is used by [Bevy](https://bevyengine.org/), [Zed](https://zed.dev/), [Lapce](https://lapce.dev/), [Iced](https://github.com/iced-rs/iced), and many more.
|
||||
|
||||
- Autoformatting of our meta language (RSX) and accompanying [VSCode extension](https://marketplace.visualstudio.com/items?itemName=DioxusLabs.dioxus)
|
||||
- Hotreloading using an interpreter of RSX for both desktop and web
|
||||
- Emphasis on good docs - our guide is complete and our HTML elements are documented
|
||||
- Significant research in simplifying
|
||||
Dioxus places an emphasis on a few key points that make it different from other frameworks:
|
||||
|
||||
Dioxus is also a very extensible platform.
|
||||
- **React-like**: we rely on concepts like components, props, and hooks to build UIs, with our state management being closer to Svelte than to SolidJS.
|
||||
- **HTML and CSS**: we lean completely into HTML and CSS, quirks and all.
|
||||
- **Renderer-agnostic**: you can swap out the renderer for any platform you want thanks to [our fast VirtualDOM](https://dioxuslabs.com/blog/templates-diffing).
|
||||
- **Collaborative**: whenever possible, we spin out crates like [Taffy](https://github.com/DioxusLabs/taffy), [magnanis](https://github.com/DioxusLabs/collect-assets), [include_mdbook](https://github.com/DioxusLabs/include_mdbook), and [blitz](http://github.com/dioxusLabs/blitz) so the ecosystem can grow together.
|
||||
|
||||
- Easily build new renderers by implementing a very simple optimized stack-machine
|
||||
- Build and share components and even custom elements
|
||||
|
||||
So... Dioxus is great, but why won't it work for me?
|
||||
- It's not fully mature yet. APIs are still shifting, things might break (though we try to avoid it)
|
||||
- You need to run in a no-std environment.
|
||||
- You don't like the React-hooks model of building UIs
|
||||
### Dioxus vs Tauri
|
||||
|
||||
Tauri is a framework for building desktop (and soon, mobile) apps where your frontend is written in a web-based framework like React, Vue, Svelte, etc. Whenever you need to do native work, you can write Rust functions and call them from your frontend.
|
||||
|
||||
- **Natively Rust**: Tauri's architecture limits your UI to either JavaScript or WebAssembly. With Dioxus, your Rust code is running natively on the user's machine, letting you do things like spawning threads, accessing the filesystem, without any IPC bridge. This drastically simplifies your app's architecture and makes it easier to build. You can build a Tauri app with Dioxus-Web as a frontend if you'd like.
|
||||
|
||||
- **Different scopes**: Tauri needs to support JavaScript and its complex build tooling, limiting the scope of what you can do with it. Since Dioxus is exclusively focused on Rust, we're able to provide extra utilities like Server Functions, advanced bundling, and a native renderer.
|
||||
|
||||
- **Shared DNA**: While Tauri and Dioxus are separate projects, they do share libraries like Tao and Wry: windowing and webview libraries maintained by the Tauri team.
|
||||
|
||||
### Dioxus vs Leptos
|
||||
|
||||
Leptos is a library for building fullstack web-apps, similar to SolidJS and SolidStart. The two libraries share similar goals on the web, but have several key differences:
|
||||
|
||||
- **Reactivity model**: Leptos uses signals for its underlying reactivity, while Dioxus opts for a VirtualDom and re-renders. While in theory signals are more efficient, in practice, Dioxus' VirtualDom performs little-to-no actual diffing (thanks to our [block-dom inspired templates](https://dioxuslabs.com/blog/templates-diffing)) and is [actually faster than Leptos](https://krausest.github.io/js-framework-benchmark/2024/table_chrome_123.0.6312.59.html).
|
||||
|
||||
- **Control flow**: Because Leptos uses signals for reactivity, you are constrained to Leptos' primitives for things like `for` loops and `if` statements. If you get this wrong, your app will lose reactivity, leading to hard to debug UI issues. With Dioxus, you can use iterators, regular Rust `for` loops and `if` statements, and your app will still be reactive. In practice, a Dioxus component to insert counters into a list might look like this:
|
||||
```rust
|
||||
fn Counters() -> Element {
|
||||
let mut counters = use_signal(|| vec![0; initial_length]);
|
||||
|
||||
rsx! {
|
||||
button { onclick: move |_| counters.push(counters.len()); "Add Counter" }
|
||||
ul {
|
||||
for idx in 0..counters.len() {
|
||||
li {
|
||||
button { onclick: move |_| counters[idx] += 1; "{counters[idx]}" }
|
||||
button { onclick: move |_| { counters.write().remove(idx); } "Remove" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
While in Leptos, you would need to track keys, use the `<For>` component, create new signals, and manually clean up memory:
|
||||
```rust
|
||||
fn Counters() -> Element {
|
||||
let initial_counters = (0..initial_length)
|
||||
.map(|id| (id, create_signal(id + 1)))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let (counters, set_counters) = create_signal(initial_counters);
|
||||
|
||||
let add_counter = move |_| {
|
||||
let sig = create_signal(next_counter_id + 1);
|
||||
set_counters.update(move |counters| counters.push((next_counter_id, sig)));
|
||||
next_counter_id += 1;
|
||||
};
|
||||
|
||||
view! {
|
||||
<div>
|
||||
<button on:click=add_counter>
|
||||
"Add Counter"
|
||||
</button>
|
||||
<ul>
|
||||
<For
|
||||
each=counters
|
||||
key=|counter| counter.0
|
||||
children=move |(id, (count, set_count))| {
|
||||
view! {
|
||||
<li>
|
||||
<button
|
||||
on:click=move |_| set_count.update(|n| *n += 1)
|
||||
>
|
||||
{count}
|
||||
</button>
|
||||
<button
|
||||
on:click=move |_| {
|
||||
set_counters.update(|counters| {
|
||||
counters.retain(|(counter_id, (signal, _))| {
|
||||
|
||||
if counter_id == &id {
|
||||
signal.dispose();
|
||||
}
|
||||
counter_id != &id
|
||||
})
|
||||
});
|
||||
}
|
||||
>
|
||||
"Remove"
|
||||
</button>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
/>
|
||||
</ul>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- **`Copy` state**: Dioxus 0.1 to 0.4 relied on lifetimes to relax the rules of Rust's borrow checker. This worked well for event handlers, but struggled around async. In Dioxus 0.5, we've switched to a [`Copy` state model](https://crates.io/crates/generational-box) borrowed from Leptos.
|
||||
|
||||
- **Different scopes**: Dioxus provides renderers for web, desktop, mobile, LiveView, and more. We also maintain community libraries and a cross-platform SDK. The scope of this work is huge, meaning we've historically released at a slower cadence than Leptos. Leptos focuses on the fullstack web, with features that Dioxus doesn't have like `<Suspense />`-based streaming HTML, islands, `<Form />` components, and other web-specific features. Generally, web apps you build with Leptos will have a smaller footprint.
|
||||
|
||||
- **Different DSLs**: While both frameworks target the web, Dioxus uses its own custom Rust-like DSL for building UIs while Leptos uses a more HTML-like syntax. We chose this to retain compatibility with IDE features like codefolding and syntax highlighting. Generally, Dioxus leans into more "magic" with its DSL. For example, dioxus will automatically format strings for you while Leptos requires you to use closures and `format!` or `format_args!`.
|
||||
```rust
|
||||
// dioxus
|
||||
rsx! {
|
||||
div { class: "my-class", enabled: true, "Hello, {name}" }
|
||||
}
|
||||
|
||||
// leptos
|
||||
view! {
|
||||
<div class="my-class" enabled={true}>
|
||||
"Hello "
|
||||
{move || name()}
|
||||
</div>
|
||||
}
|
||||
```
|
||||
|
||||
### Dioxus vs Yew
|
||||
|
||||
Yew is a framework for building single-page web apps and initially served as an inspiration for Dioxus. Unfortunately, the architecture of Yew didn't support the various features we wanted, and thus Dioxus was born.
|
||||
|
||||
- **Single-page apps**: Yew is designed exclusively for single-page web apps and is instrinsically tied to the web platform. Dioxus is fullstack and crossplatform, making it suitable for building web, desktop, mobile, and server apps.
|
||||
|
||||
- **Developer Tooling**: Dioxus provides a number of utilities like autoformatting, hotreloading, and a bundler.
|
||||
|
||||
- **Ongoing support**: Dioxus is very actively maintained with new features and bug fixes being added on a daily basis.
|
||||
|
||||
### Dioxus vs egui
|
||||
|
||||
egui is a cross-platform GUI library for Rust powering tools like [Rerun.io](https://www.rerun.io).
|
||||
|
||||
- **Immediate vs Retained**: egui is designed to be re-rendered on every frame. This is suitable for games and other interactive applications, but it does not retain style and layout state between frames. Dioxus is a retained UI framework, meaning that the UI is built once and then modified between frames. This enables Dioxus to use native web technologies like HTML and CSS with better battery life and performance.
|
||||
|
||||
- **Customizable**: egui brings its own styling and layout solution while Dioxus expects you to use the built-in HTML and CSS. This enables dioxus apps to use any CSS library like Tailwind or Material UI.
|
||||
|
||||
- **State management**: egui's state management is based on a single global state object. Dioxus encourages encapsulation of state by using components and props, making components more reusable.
|
||||
|
||||
### Dioxus vs Iced
|
||||
|
||||
Iced is a cross-platform GUI library inspired by Elm. Iced renders natively with WGPU and supports the web using DOM nodes.
|
||||
|
||||
- **Elm state management**: Iced uses Elm's state management model, which is based on message passing and reducers. This is simply a different state management model than Dioxus and can be rather verbose at times.
|
||||
|
||||
- **Native Feel**: Since Dioxus uses a webview as its renderer, it automatically gets native text input, paste handling, and other native features like accessibility. Iced's renderer currently doesn't implement these features, making it feel less native.
|
||||
|
||||
- **WGPU**: Dioxus' WGPU renderer is currently quite immature and not yet reader for production use. Iced's WGPU renderer is much more mature and is being used in production. This enables certain types of apps that need GPU access to be built with Iced that can't currently be built with Dioxus.
|
||||
|
||||
### Dioxus vs Electron
|
||||
|
||||
Dioxus and Electron are two entirely different projects with similar goals. Electron makes it possible for developers to build cross-platform desktop apps using web technologies like HTML, CSS, and JavaScript.
|
||||
|
||||
- **Lightweight**: Dioxus uses the system's native WebView - or optionally, a WGPU renderer - to render the UI. This makes a typical Dioxus app about 15mb on macOS in comparison to Electron's 100mb. Electron also ships an embedded chromium instance which cannot share system resources with the host OS in the same way as Dioxus.
|
||||
|
||||
- **Maturity**: Electron is a mature project with a large community and a lot of tooling. Dioxus is still quite young in comparison to Electron. Expect to run into features like deeplinking that require extra work to implement.
|
||||
|
||||
|
||||
## Contributing
|
||||
|
|
BIN
notes/autofmt.gif
Normal file
BIN
notes/autofmt.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 456 KiB |
BIN
notes/bundle.gif
Normal file
BIN
notes/bundle.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 612 KiB |
BIN
notes/dioxus-community.avif
Normal file
BIN
notes/dioxus-community.avif
Normal file
Binary file not shown.
BIN
notes/dioxus_splash_8.avif
Normal file
BIN
notes/dioxus_splash_8.avif
Normal file
Binary file not shown.
BIN
notes/docs.avif
Normal file
BIN
notes/docs.avif
Normal file
Binary file not shown.
20
notes/header-dark.svg
Normal file
20
notes/header-dark.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 28 KiB |
20
notes/header-light.svg
Normal file
20
notes/header-light.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 28 KiB |
BIN
notes/hotreload.gif
Normal file
BIN
notes/hotreload.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 376 KiB |
Loading…
Reference in a new issue