Getting Started
I encourage you to first learn about Dioxus, when you are done you can continue here. Also make sure you have the followed the Setup guide.
Now, let's start by creating a hello world project.
Creating the project
mkdir freya-app
cd freya-app
cargo init
Cargo.toml
Let's add Freya and Dioxus, but this last one with only 2 features selected as we don't want to pull unnecessary dependencies.
[package]
name = "freya-app"
version = "0.1.0"
edition = "2021"
[dependencies]
freya = "0.2"
dioxus = { version = "0.5", features = ["macro", "hooks"], default-features = false }
src/main.rs
You pass your root (usually named app
) component to the launch
function, which will open the window and then render your component.
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
use freya::prelude::*;
fn main() {
launch(app); // Be aware that this will block the thread
}
Let's define our root component:
Components in Freya are just functions that return an Element
and might receive some properties as arguments.
Let's make it stateful by using Signals from Dioxus:
Running
Simply run with cargo
:
cargo run
Nice! You have created your first Freya app.
You can learn more with the examples in the repository.