Rust front-end framework for building web apps.
Valerie is still in a very early phase. A lot of features are not available at the moment. A lot of work is left and you are welcome to try it out.
nightly
Rust required.Component
trait.Node
.StateAtomic
for types implementing Copy
.StateMutex
for types implementing Clone
.cargo new --lib some_name
valerie
to the dependenciesstatic
directory and create an index.html
inside ithtml
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Title</title>
<script type="module">
import init from "./wasm.js"
init()
</script>
</head>
<body></body>
</html>
Cargo.toml
enable lto.toml
[profile.release]
lto = true
opt-level = 3
wasm-pack
by running
wasm-pack build --target web --out-name wasm --out-dir ./static
miniserve
,
to host the ./static
folder and try it out.Take a look at wasm-pack
docs for more options.
```rust use valerie::prelude::components::; use valerie::prelude::;
fn ui() -> Node { h1!("Hello World").into() }
pub fn run() { App::render_single(ui()); } ```
```rust use valerie::prelude::components::; use valerie::prelude::;
fn ui() -> Node { let value = StateAtomic::new(0isize);
div!(
h1!("Value ", value.clone()),
button!("Add 1")
.on_event("click", value.clone(), move |x, _| {
*x += 1;
}),
button!("Subtract 1")
.on_event("click", value.clone(), move |x, _| {
*x -= 1;
})
)
.into()
}
pub fn run() { App::render_single(ui()); } ```
```rust use valerie::prelude::components::; use valerie::prelude::; use wasm_timer::Delay;
fn ui() -> web_sys::Node { let timer = StateAtomic::new(0);
execute(time(1, timer.clone()));
p!("Seconds passed: ", timer).into()
}
async fn time(n: u64, mut timer: StateAtomic
pub fn run() { App::render_single(ui()); } ```
There are more examples in the examples directory.
Since this is a new project, there are a lot of issues currently and a lot of features yet to be implemented. Please do contribute. Contribution guidelines will be up soon.