Top Related Projects
Rust / Wasm framework for creating reliable and efficient web applications
Build fast web applications with Rust.
Fullstack app framework for web, desktop, mobile, and more.
A library for creating reactive web apps in Rust and WebAssembly
Facilitating high-level interactions between Wasm modules and JavaScript
📦✨ your favorite rust -> wasm workflow tool!
Quick Overview
Seed is a Rust framework for creating fast and reliable web apps with a reactive approach. It allows developers to build client-side web applications using Rust, compiled to WebAssembly, providing a robust and efficient alternative to JavaScript frameworks.
Pros
- Strong type safety and performance benefits of Rust
- Seamless integration with WebAssembly for efficient client-side execution
- Reactive programming model for building interactive UIs
- Excellent documentation and growing community support
Cons
- Steeper learning curve for developers not familiar with Rust
- Smaller ecosystem compared to established JavaScript frameworks
- Limited server-side rendering capabilities
- Potential for larger initial bundle sizes compared to optimized JS apps
Code Examples
- Creating a simple counter component:
#[derive(Default)]
struct Model {
count: i32,
}
enum Msg {
Increment,
Decrement,
}
fn update(msg: Msg, model: &mut Model, _: &mut impl Orders<Msg>) {
match msg {
Msg::Increment => model.count += 1,
Msg::Decrement => model.count -= 1,
}
}
fn view(model: &Model) -> Node<Msg> {
div![
button![ev(Ev::Click, |_| Msg::Decrement), "-"],
span![model.count],
button![ev(Ev::Click, |_| Msg::Increment), "+"],
]
}
- Fetching data from an API:
async fn fetch_data() -> fetch::Result<String> {
Request::new("https://api.example.com/data")
.method(Method::Get)
.fetch()
.await?
.text()
.await
}
fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
match msg {
Msg::FetchData => {
orders.perform_cmd(async {
match fetch_data().await {
Ok(data) => Msg::DataFetched(data),
Err(_) => Msg::FetchFailed,
}
});
}
// Handle other messages...
}
}
- Creating a routing system:
#[derive(Clone, Serialize, Deserialize)]
enum Route {
Home,
About,
Contact,
}
fn view(model: &Model) -> Node<Msg> {
div![
nav![
a![attrs! {At::Href => "/"}, "Home"],
a![attrs! {At::Href => "/about"}, "About"],
a![attrs! {At::Href => "/contact"}, "Contact"],
],
match model.route {
Route::Home => home_page(),
Route::About => about_page(),
Route::Contact => contact_page(),
}
]
}
Getting Started
-
Install Rust and cargo-make:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh cargo install cargo-make
-
Create a new Seed project:
cargo new --lib my_app cd my_app
-
Add Seed dependency to Cargo.toml:
[dependencies] seed = "0.9.2"
-
Build and run the project:
cargo make start
This will compile your Rust code to WebAssembly and start a local development server.
Competitor Comparisons
Rust / Wasm framework for creating reliable and efficient web applications
Pros of Yew
- Larger community and ecosystem, with more resources and third-party components
- Better performance for complex applications due to its virtual DOM implementation
- More flexible routing options and built-in router support
Cons of Yew
- Steeper learning curve, especially for developers new to Rust
- More verbose syntax and boilerplate code compared to Seed
- Potentially slower compilation times for large projects
Code Comparison
Yew example:
use yew::prelude::*;
#[function_component(App)]
fn app() -> Html {
html! {
<h1>{"Hello, World!"}</h1>
}
}
Seed example:
use seed::{prelude::*, *};
fn view(_model: &Model) -> Node<Msg> {
h1!["Hello, World!"]
}
Both Yew and Seed are popular Rust frameworks for building web applications. Yew offers a more React-like experience with its component model and virtual DOM, while Seed provides a simpler, more lightweight approach. Yew is generally better suited for larger, more complex applications, while Seed may be preferable for smaller projects or developers looking for a gentler introduction to Rust web development.
Build fast web applications with Rust.
Pros of Leptos
- Utilizes fine-grained reactivity, offering better performance for complex applications
- Supports server-side rendering (SSR) out of the box
- Provides a more flexible routing system
Cons of Leptos
- Steeper learning curve due to its more complex reactivity system
- Less mature ecosystem compared to Seed
Code Comparison
Leptos:
#[component]
fn App() -> impl IntoView {
let (count, set_count) = create_signal(0);
view! {
<button on:click=move |_| set_count.update(|n| *n + 1)>
"Click me: " {count}
</button>
}
}
Seed:
fn view(model: &Model) -> Node<Msg> {
button![
"Click me: ", model.count,
ev(Ev::Click, |_| Msg::Increment),
]
}
Both Leptos and Seed are Rust frameworks for building web applications. Leptos offers fine-grained reactivity and built-in SSR support, making it potentially more suitable for complex applications. However, it has a steeper learning curve. Seed, on the other hand, has a simpler API and a more mature ecosystem, but may not perform as well for highly dynamic applications. The code comparison shows that Leptos uses a more declarative approach with signals, while Seed relies on a more traditional model-view-update pattern.
Fullstack app framework for web, desktop, mobile, and more.
Pros of Dioxus
- Supports multiple rendering backends (Web, Desktop, Mobile)
- More active development and larger community
- Better performance, especially for complex applications
Cons of Dioxus
- Steeper learning curve due to more advanced features
- Less stable API, as it's still in active development
- Larger bundle size compared to Seed
Code Comparison
Seed example:
#[update]
fn increment() {
model.counter += 1;
}
#[view]
fn view() -> Node<Msg> {
button![ simple_ev(Ev::Click, Msg::Increment), "+1" ]
}
Dioxus example:
#[component]
fn Counter(cx: Scope) -> Element {
let mut count = use_state(cx, || 0);
cx.render(rsx! {
button { onclick: move |_| count += 1, "+1" }
})
}
Both frameworks offer a declarative approach to building user interfaces in Rust. Seed focuses on simplicity and ease of use, making it a good choice for smaller projects or developers new to Rust web development. Dioxus, on the other hand, provides more advanced features and better performance, making it suitable for larger, more complex applications across multiple platforms.
A library for creating reactive web apps in Rust and WebAssembly
Pros of Sycamore
- Uses fine-grained reactivity, potentially offering better performance
- Supports both CSR and SSR out of the box
- Has a more flexible component model
Cons of Sycamore
- Smaller community and ecosystem compared to Seed
- Less mature, with potential for more breaking changes
- Steeper learning curve due to its reactive programming model
Code Comparison
Sycamore:
#[component]
fn App<G: Html>(cx: Scope) -> View<G> {
let count = create_signal(cx, 0);
view! { cx,
button(on:click=move |_| count.set(count.get() + 1)) { "Increment" }
p { "Count: " (count.get()) }
}
}
Seed:
fn view(model: &Model) -> Node<Msg> {
button![
"Increment",
ev(Ev::Click, |_| Msg::Increment)
]
p!["Count: ", model.count]
}
Both Sycamore and Seed are Rust frameworks for building web applications. Sycamore offers a more reactive approach with fine-grained updates, while Seed provides a simpler, more traditional model. Sycamore's flexibility comes at the cost of complexity, while Seed's simplicity may limit advanced use cases. The choice between them depends on project requirements and developer preferences.
Facilitating high-level interactions between Wasm modules and JavaScript
Pros of wasm-bindgen
- Lower-level and more flexible, allowing for fine-grained control over JavaScript interop
- Broader ecosystem support and integration with other Rust-WASM tools
- More mature project with extensive documentation and examples
Cons of wasm-bindgen
- Requires more boilerplate code for setting up web applications
- Steeper learning curve for developers new to Rust and WebAssembly
- Less opinionated, which can lead to inconsistent application structure
Code Comparison
wasm-bindgen:
#[wasm_bindgen]
pub fn greet(name: &str) -> String {
format!("Hello, {}!", name)
}
seed:
#[update]
fn greet(name: String) -> String {
format!("Hello, {}!", name)
}
Both examples show a simple greeting function, but wasm-bindgen requires explicit attribute annotations for JavaScript interop, while seed uses a more declarative approach with its own attribute system.
wasm-bindgen provides a lower-level interface for Rust-WASM integration, offering more flexibility but requiring more setup. seed, on the other hand, provides a higher-level framework specifically designed for building web applications, with a focus on simplicity and productivity at the cost of some flexibility.
📦✨ your favorite rust -> wasm workflow tool!
Pros of wasm-pack
- More general-purpose tool for building and working with WebAssembly
- Supports multiple JavaScript environments (Node.js, browsers)
- Integrates well with existing JavaScript toolchains
Cons of wasm-pack
- Requires more setup and configuration for web projects
- Less opinionated, which can lead to more decision-making for developers
- Steeper learning curve for those new to WebAssembly
Code Comparison
Seed example:
#[wasm_bindgen(start)]
pub fn render() {
App::start("app", init, update, view);
}
wasm-pack example:
#[wasm_bindgen]
pub fn greet(name: &str) -> String {
format!("Hello, {}!", name)
}
Summary
Seed is a framework specifically designed for building web applications with Rust and WebAssembly, offering a more opinionated and streamlined approach. wasm-pack, on the other hand, is a more versatile tool for working with WebAssembly in various contexts, providing greater flexibility but requiring more setup and knowledge from developers. Seed may be easier for web-specific projects, while wasm-pack offers broader application support.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Website | Discord
Seed is a Rust front-end framework for creating fast and reliable web apps with an Elm-like architecture.
- completely written in Rust, including the templating system (e.g.
div!
macro). - built-in state management that is based on the Elm architecture.
- clear and extensive documentation for Rust beginners and pros alike.
- WebAssembly.
Why Seed?
Seed allows you to develop the front-end with all the benefits of Rust, meaning speed, safety, and too many more things to count.
The Seed templating system uses a macro syntax that makes Rustaceans feel right at home. This means linting, formatting, and commenting will work, and it's all in Rust. This is opposed to a JSX-like syntax that relies on IDE extensions to improve the developer experience.
Why not Seed?
- It's not maintained at the moment.
- WebAssembly is newer with less support. Browser compatibility is at 95.5%.
- Pre-built components are rare. You will likely have to roll your own components such as date pickers.
- No server-side rendering yet #232.
- You may prefer other Rust frameworks
Getting Started
To get started right away, we can use the quickstart template:
cargo install cargo-generate
cargo install trunk
cargo install wasm-bindgen-cli
cargo generate --git https://github.com/seed-rs/seed-quickstart.git --name seed-quickstart
cd seed-quickstart
trunk serve
If you get an error about wasm being linked against a different version of wasm-bindgen
, just follow the suggestion to run cargo update -p wasm-bindgen
. This will fix the linkings.
You should now see a working counter app in your browser at localhost:8080
.
Getting into Seed
The Seed website and the library docs are the best way to learn about the functionalities of Seed.
The Seed examples are another good resource.
Trunk is the recommended application bundler for Seed.
Seed projects are typically run with trunk serve
instead of cargo run
.
You might also see cargo make start project_name
in the examples. Going forward, we recommend using Trunk.
Seed Styles is a styling library for Seed to create global and scoped styles.
To use web APIs, there is web-sys
which is a part of the wasm-bindgen
project. wasm-bindgen
is a dependency of Seed.
There are also two template repositories. However, they are not currently up to date.
FAQ
How stable is Seed?
As a framework, Seed is mostly feature-complete. You can build complete web apps in Seed.
Projects built in Seed do use Rust stable
. Being in Rust, it's easy to create robust, predictable programs.
What's next for Seed?
Seed is not maintained at the moment but if you want to see some features and bring a budget, feel free to contact us.
Documentation
- Guides can be found at seed-rs.org
- API documentation can be found at docs.rs/seed
Resources
- Awesome-seed-rs: A curated list of resources
- Seed Realworld: A detailed realworld example (outdated but still helpful)
- Engineering Rust Web Applications: A book describing full-stack Rust web development using Seed (oudated but still helpful)
Contributing
See CONTRIBUTING.md.
Supported By
See BACKERS.md.
Top Related Projects
Rust / Wasm framework for creating reliable and efficient web applications
Build fast web applications with Rust.
Fullstack app framework for web, desktop, mobile, and more.
A library for creating reactive web apps in Rust and WebAssembly
Facilitating high-level interactions between Wasm modules and JavaScript
📦✨ your favorite rust -> wasm workflow tool!
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot