Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Rust Front-end with Yew
Search
Ciro Nunes
September 14, 2022
Programming
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rust Front-end with Yew
Ciro Nunes
September 14, 2022
Transcript
42 slides
Ciro Nunes 14 Sep 22 Rust Front-end with Yew 🦀🇦🇺
Agenda ⁉ What is Yew? Why Wasm & Rust? 🪄
Simple tutorial 🤩 My impressions 🗺 Where to go from here
What is Yew? Why Wasm & 🦀?
What is Yew?
Yew Rust / Wasm client web app framework
Yew Multi-threaded front-end web apps using WebAssembly 🏎💨
Yew Multi-threaded front-end web apps using WebAssembly 🏎💨 • Component-based
Yew Multi-threaded front-end web apps using WebAssembly 🏎💨 • Component-based
• Great performance
Yew Multi-threaded front-end web apps using WebAssembly 🏎💨 • Component-based
• Great performance • JavaScript interoperability
Why Wasm?
WebAssembly Low-level assembly-like language with a compact binary format that
runs with near-native performance and provides languages like Rust with a compilation target that can run in modern web browsers.
WebAssembly Not a silver bullet for improving performance of web
apps 🤪
WebAssembly Not a silver bullet for improving performance of web
apps 🤪 • DOM APIs from Wasm are still slower than directly from JS
WebAssembly Not a silver bullet for improving performance of web
apps 🤪 • DOM APIs from Wasm are still slower than directly from JS • Perfect for heavy computation applications
WebAssembly Not a silver bullet for improving performance of web
apps 🤪 • DOM APIs from Wasm are still slower than directly from JS • Perfect for heavy computation applications • Multi-threading via Web Workers
Why Rust?
Rust Helps developers write safer code with its rich type
system and ownership model
Simple tutorial
Let’s build a To-do app
None
None
# [ derive(Clone)] struct Todo { text: String, completed: bool,
}
struct TodoComponent { todos: Vec<Todo>, new_todo_txt: String, }
enum Msg { AddTodo, UpdateNewTodo(String), }
impl Component for TodoComponent { type Message = Msg; type
Properties = (); fn create(_ctx: &Context<Self>) - > Self {} fn update(&mut self,_ctx, msg: Self : : Message) - > bool {} fn view(&self, ctx: &Context<Self>) - > Html {} }
fn create(_ctx: &Context<Self>) - > Self { Self { todos:
vec![Todo { text: "Learn Rust".to_string(), completed: true, }], new_todo_txt: "".to_string(), } }
fn view(&self, ctx: &Context<Self>) - > Html { let link
= ctx.link(); let on_cautious_change = link.batch_callback(|e: Event| { let input = e.target_dyn_into: : < HtmlInputElement>(); input.map(|input| Msg : : UpdateNewTodo(input.value())) }); html! { <div> <ol> { self.todos.iter().map(|todo| html! { <li> <input type="checkbox" checked={todo.completed} / > <span>{format!("{}", todo.text)} < / span> < / li> }).collect: : < Html>()} < / ol> <div> <input type="text" value={self.new_todo_txt.to_string()} onchange={on_cautious_change} / > <button onclick={link.callback(|_| Msg : : AddTodo)}>{ "Add" } < / button> < / div> < / div> } }
fn update(&mut self, _ctx: &Context<Self>, msg: Self : : Message)
- > bool { match msg { Msg : : AddTodo = > { let new_todo = Todo { text: self.new_todo_txt.to_string(), completed: false, }; self.new_todo_txt = "".to_string(); self.todos.push(new_todo); true } Msg : : UpdateNewTodo(new_txt) = > { self.new_todo_txt = new_txt; true } } }
use yew : : prelude : : *; fn main()
{ yew : : start_app: : < TodoComponent>(); }
My impressions
My impressions Yew
My impressions Yew • Very similar to React, but it’s
Rust
My impressions Yew • Very similar to React, but it’s
Rust • Easy to setup and learn the basics
My impressions Yew • Very similar to React, but it’s
Rust • Easy to setup and learn the basics • Good documentation
My impressions Yew • Very similar to React, but it’s
Rust • Easy to setup and learn the basics • Good documentation • Looks promising
Where to go from here
Where to go from here Yew
Where to go from here Yew • Check out the
docs yew.rs
Where to go from here Yew • Check out the
docs yew.rs • Learn about Properties, Function Components, Hooks, Agents and the Router
Where to go from here Yew • Check out the
docs yew.rs • Learn about Properties, Function Components, Hooks, Agents and the Router • Checkout stylist for CSS-in-Rust
Where to go from here Yew • Check out the
docs yew.rs • Learn about Properties, Function Components, Hooks, Agents and the Router • Checkout stylist for CSS-in-Rust • Take advantage of Rust parallelism in Wasm for heavy computations
Thanks for listening ✌
More Decks by Ciro Nunes
See All by Ciro Nunes
Type safe CSS with Reason
cironunes
0
170
What I've learned building automated docs for Ansarada's design system
cironunes
0
110
Beyond ng new
cironunes
2
270
Animate your Angular apps
cironunes
0
480
Sweet Angular, good forms never felt so good
cironunes
0
120
Sweet Angular, good forms never felt so good
cironunes
0
340
Progressive Angular apps
cironunes
3
960
Angular: Um framework. Mobile & desktop.
cironunes
1
630
Firebase & Angular
cironunes
0
320
Other Decks in Programming
See All in Programming
[DroidKnights 2026] Workflow AX: From Auto-Documented Policies to E2E Testing
raeminkang
0
620
エラーチャンネルのボールを拾い続けて鍛えるエンジニアの地力 / phpcon-niigata2026
meihei3
1
590
SONY CISC-NEWS NWS-1750 + NWB-225 ハードウェアメンテとフレームバッファカラー対応 / KOF2026
tsutsui
0
150
[DroidKnights 2026] Workflow AX 적용기 — 자동 정책 정리부터 E2E까지
dayeon
0
130
How SRE Grew Out of Server-Side Work and Became the Team's Own / サーバサイドから始まったSREを チームに渡すまで
maaaato
1
390
祈るテストから、探索するテストへ 〜Lincheckではじめる並行処理テスト〜
yyh_gl
0
440
Kotlin JVM用に作られたライブラリのKMPを前提とした再設計
jsoizo
0
240
[Kotlin Fest 2026] eBPF Tracing for Kotlin
takehaya
1
410
なぜ私たちは「現時点では」KMPの導入を見送ったのか
chigichan24
1
650
Datadog を OTel にするメリットを考察する — Datadog との併用を実アプリで確かめる / Examining the Benefits of Moving Datadog to OTel — Testing OTel Alongside Datadog in a Real App
seike460
PRO
1
120
Debian JP Projectのサーバー構成
uwabami
1
190
The Cost of the DOM
ypresto
6
3.6k
Featured
See All Featured
Speed Design
sergeychernyshev
33
2.3k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.7k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.3k
The SEO identity crisis: Don't let AI make you average
varn
0
630
Accessibility Awareness
sabderemane
1
320
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.8k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.8k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
530
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
890
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
1.1k