2021-01-16 15:31:17 +00:00
< div align = "center" >
< h1 > 🌗🚀 Dioxus< / h1 >
< p >
2021-03-02 06:47:27 +00:00
< strong > Frontend that scales.< / strong >
2021-01-16 15:31:17 +00:00
< / p >
< / div >
2021-02-08 21:57:34 +00:00
Dioxus is a portable, performant, and ergonomic framework for building cross-platform user experiences in Rust.
2021-01-16 06:30:48 +00:00
2021-02-08 21:57:34 +00:00
```rust
2021-06-17 22:00:32 +00:00
fn Example(cx: Context< ()>) -> VNode {
2021-07-01 18:14:59 +00:00
let name = use_state(cx, || "..?");
2021-02-25 23:44:00 +00:00
2021-06-17 22:00:32 +00:00
cx.render(rsx! {
2021-06-30 21:20:13 +00:00
h1 { "Hello, {name}" }
button { "?", onclick: move |_| name.set("world!")}
button { "?", onclick: move |_| name.set("Dioxus 🎉")}
2021-03-01 02:21:17 +00:00
})
2021-02-08 21:57:34 +00:00
};
```
2021-06-17 22:00:32 +00:00
Dioxus can be used to deliver webapps, desktop apps, static pages, liveview apps, eventually mobile apps (WIP), and more. At its core, Dioxus is entirely renderer agnostic and has great documentation for creating new renderers for any platform.
2021-02-14 23:03:16 +00:00
2021-06-01 22:33:15 +00:00
If you know React, then you already know Dioxus.
2021-03-01 05:16:48 +00:00
### **Things you'll love ❤️:**
2021-06-01 22:33:15 +00:00
2021-06-30 21:20:13 +00:00
- Ergonomic design
- Minimal boilerplate
2021-06-01 22:33:15 +00:00
- Simple build, test, and deploy
2021-06-30 21:20:13 +00:00
- Compile-time correct templating
- Support for fine-grained reactivity
- Support for html! and rsx! templates
2021-03-01 05:16:48 +00:00
- SSR, WASM, desktop, and mobile support
2021-06-30 21:20:13 +00:00
- Support for asynchronous batched rendering
- Powerful and simple integrated state management
- Rust! (enums, static types, modules, efficiency)
### Key Differentiators
- Immutability by default
- Built-in suspense system
- Integrations for isomorphic apps
- Skip diffing altogether with signal API
- Extremely portable without runtime requirements
2021-03-01 05:18:05 +00:00
2021-03-01 05:16:48 +00:00
## Get Started with...
2021-06-01 22:33:15 +00:00
2021-02-08 22:09:21 +00:00
< table style = "width:100%" align = "center" >
< tr >
2021-03-29 16:31:47 +00:00
< th > < a href = "http://github.com/jkelleyrtp/dioxus" > Web< / a > < / th >
2021-02-08 22:08:26 +00:00
< th > < a href = "http://github.com/jkelleyrtp/dioxus" > Desktop< / a > < / th >
< th > < a href = "http://github.com/jkelleyrtp/dioxus" > Mobile< / a > < / th >
2021-06-15 14:02:46 +00:00
< th > < a href = "http://github.com/jkelleyrtp/dioxus" > State< / a > < / th >
2021-02-08 22:08:26 +00:00
< th > < a href = "http://github.com/jkelleyrtp/dioxus" > Docs< / a > < / th >
2021-02-08 22:09:21 +00:00
< th > < a href = "http://github.com/jkelleyrtp/dioxus" > Tools< / a > < / th >
2021-02-08 22:05:58 +00:00
< tr >
< / table >
2021-02-08 22:07:27 +00:00
2021-02-16 06:41:41 +00:00
## Explore
2021-06-01 22:33:15 +00:00
2021-06-30 20:47:30 +00:00
- [**Fine-grained reactivity**: Skip the diff overhead with signals ](docs/guides/00-index.md )
2021-03-01 05:16:48 +00:00
- [**HTML Templates**: Drop in existing HTML5 templates with html! macro ](docs/guides/00-index.md )
- [**RSX Templates**: Clean component design with rsx! macro ](docs/guides/00-index.md )
2021-02-16 06:43:50 +00:00
- [**Running the examples**: Explore the vast collection of samples, tutorials, and demos ](docs/guides/00-index.md )
- [**Building applications**: Use the Dioxus CLI to build and bundle apps for various platforms ](docs/guides/01-ssr.md )
- [**Liveview**: Build custom liveview components that simplify datafetching on all platforms ](docs/guides/01-ssr.md )
- [**State management**: Easily add powerful state management that comes integrated with Dioxus Core ](docs/guides/01-ssr.md )
- [**Concurrency**: Drop in async where it fits and suspend components until new data is ready ](docs/guides/01-ssr.md )
2021-03-01 05:16:48 +00:00
- [**1st party hooks**: Cross-platform router hook ](docs/guides/01-ssr.md )
2021-02-16 06:43:50 +00:00
- [**Community hooks**: 3D renderers ](docs/guides/01-ssr.md )
2021-01-29 16:57:52 +00:00
2021-05-20 00:57:19 +00:00
## Blog Posts
2021-06-01 22:33:15 +00:00
2021-05-20 00:57:19 +00:00
- [Why we need a stronger typed web]()
- [Isomorphic webapps in 10 minutes]()
- [Rust is high level too]()
- [Eliminating crashes with Rust webapps]()
- [Tailwind for Dioxus]()
- [The monoglot startup]()
2021-06-01 22:33:15 +00:00
2021-06-03 16:02:46 +00:00
## Why?
2021-06-01 22:33:15 +00:00
TypeScript is a great addition to JavaScript, but comes with a lot of tweaking flags, a slight performance hit, and an uneven ecosystem where some of the most important packages are not properly typed. TypeScript provides a lot of great benefits to JS projects, but comes with its own "tax" that can slow down dev teams. Rust can be seen as a step up from TypeScript, supporting:
- static types for _all_ libraries
- advanced pattern matching
- immutability by default
- clean, composable iterators
- a good module system
- integrated documentation
- inline built-in unit/integration testing
- best-in-class error handling
2021-07-01 18:14:59 +00:00
- simple and fast build system (compared to webpack!)
2021-06-03 17:57:41 +00:00
- powerful standard library (no need for lodash or underscore)
2021-06-01 22:33:15 +00:00
- include_str! for integrating html/css/svg templates directly
2021-06-03 16:02:46 +00:00
- various macros (`html!`, `rsx!` ) for fast template iteration
2021-06-01 22:33:15 +00:00
And much more. Dioxus makes Rust apps just as fast to write as React apps, but affords more robustness, giving your frontend team greater confidence in making big changes in shorter time. Dioxus also works on the server, on the web, on mobile, on desktop - and it runs completely natively so performance is never an issue.
2021-06-24 15:09:38 +00:00
# Parity with React
2021-06-24 15:18:58 +00:00
Dioxus is heavily inspired by React, but we want your transition to feel like an upgrade. Dioxus is _most_ of the way there, but missing a few key features. This parity table does not necessarily include important ecosystem crates like code blocks, markdown, resizing hooks, etc.
2021-06-24 15:09:38 +00:00
2021-06-24 15:17:59 +00:00
### Phase 1: The Basics
2021-07-05 22:37:15 +00:00
| Feature | Dioxus | React | Notes for Dioxus |
| ----------------------- | ------ | ----- | ----------------------------------------------------- |
| Conditional Rendering | ✅ | ✅ | if/then to hide/show component |
2021-07-07 17:51:55 +00:00
| Map, Iterator | ✅ | ✅ | map/filter/reduce to produce rsx! |
2021-07-05 22:37:15 +00:00
| Keyed Components | ✅ | ✅ | advanced diffing with keys |
| Web | ✅ | ✅ | renderer for web browser |
| Desktop (webview) | ✅ | ✅ | renderer for desktop |
2021-07-07 17:51:55 +00:00
| Shared State (Context) | ✅ | ✅ | share state through the tree |
2021-07-05 22:37:15 +00:00
| Hook | ✅ | ✅ | memory cells in components |
| SSR | ✅ | ✅ | render directly to string |
| Component Children | ✅ | ✅ | cx.children() as a list of nodes |
2021-07-07 17:51:55 +00:00
| Headless components | ✅ | ✅ | components that don't return real elements |
| Fragments | ✅ | ✅ | multiple elements without a real root |
2021-07-05 22:37:15 +00:00
| Manual Props | ✅ | ✅ | Manually pass in props with spread syntax |
| Controlled Inputs | ✅ | ✅ | stateful wrappers around inputs |
2021-07-07 17:51:55 +00:00
| CSS/Inline Styles | ✅ | ✅ | syntax for inline styles/attribute groups |
| Custom elements | ✅ | ✅ | Define new element primitives |
| Compile-time correct | ✅ | ✅ | Throw errors on invalid template layouts |
| 1st class global state | ✅ | ❓ | redux/recoil/mobx on top of context |
2021-07-05 22:37:15 +00:00
| Suspense | 🛠 | ✅ | schedule future render from future/promise |
| Cooperative Scheduling | 🛠 | ✅ | Prioritize important events over non-important events |
| Fine-grained reactivity | 🛠 | ❓ | Skip diffing for fine-grain updates |
| Runs natively | ✅ | ❓ | runs as a portable binary w/o a runtime (Node) |
2021-07-07 17:51:55 +00:00
| NodeRef | 🛠 | ✅ | gain direct access to nodes [1] |
2021-06-25 13:31:13 +00:00
2021-06-25 13:35:01 +00:00
- [1] Currently blocked until we figure out a cross-platform way of exposing an imperative Node API.
2021-06-24 15:17:59 +00:00
### Phase 2: Advanced Toolkits
2021-06-25 17:17:18 +00:00
| Feature | Dioxus | React | Notes for Dioxus |
| --------------------- | ------ | ----- | ---------------------------------- |
2021-07-05 22:37:15 +00:00
| 1st class router | 👀 | ✅ | Hook built on top of history |
| Assets | 👀 | ✅ | include css/svg/img url statically |
| Integrated classnames | 🛠 | ❓ | built-in `classnames` |
| Transition | 👀 | 🛠 | High-level control over suspense |
| Animation | 👀 | ✅ | Spring-style animations |
| Mobile | 👀 | ✅ | Render with cacao |
| Desktop (native) | 👀 | ✅ | Render with native desktop |
| 3D Renderer | 👀 | ✅ | react-three-fiber |
2021-06-24 15:17:59 +00:00
### Phase 3: Additional Complexity
| Feature | Dioxus | React | Notes for Dioxus |
| -------------------- | ------ | ----- | ------------------------------------ |
2021-07-05 22:37:15 +00:00
| Portal | ❓ | ✅ | cast elements through tree |
| Error/Panic boundary | ❓ | ✅ | catch panics and display custom BSOD |
| Code-splitting | 👀 | ✅ | Make bundle smaller/lazy |
| LiveView | 👀 | ❓ | Example for SSR + WASM apps |
2021-06-24 15:15:25 +00:00
2021-06-24 15:15:55 +00:00
- ✅ = implemented and working
- 🛠 = actively being worked on
2021-06-25 13:33:59 +00:00
- 👀 = not yet implemented or being worked on
2021-06-24 15:15:55 +00:00
- ❓ = not sure if will or can implement