Skip to content

Instantly share code, notes, and snippets.

@lupyuen
Last active August 19, 2022 07:17
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lupyuen/5566af817e964ecf25488e5cbe8c2ea1 to your computer and use it in GitHub Desktop.
Save lupyuen/5566af817e964ecf25488e5cbe8c2ea1 to your computer and use it in GitHub Desktop.
Rust GUI App on PinePhone with Tauri + Yew

Rust GUI App on PinePhone with Tauri + Yew

Rust GUI App on PinePhone with Tauri + Yew

Tested on PinePhone Manjaro Phosh. Instructions modified from https://github.com/stevepryde/tauri-yew-demo

SSH to PinePhone and run these steps...

Install wasm-bindgen-cli...

rustup target add wasm32-unknown-unknown
cargo install wasm-bindgen-cli

Install tauri-cli...

cargo install tauri-cli --git https://github.com/tauri-apps/tauri --branch next

(See tauri-apps/tauri#3050)

cargo install trunk fails (out of RAM?), so we build trunk ourselves...

cd ~
git clone --recursive https://github.com/thedodd/trunk
cd trunk
cargo build
sudo cp target/debug/trunk /usr/local/bin
cd ..
rm -rf trunk

Download the demo source files and build them...

cd ~
git clone --recursive https://github.com/stevepryde/tauri-yew-demo
cd tauri-yew-demo
cargo tauri build

(Warning: Building on PinePhone the first time takes 72 mins)

Run the executable at...

src-tauri/target/release/tauri-yew-demo

The Debian Installer is at...

src-tauri/target/release/bundle/deb

The "Hello World" message is defined here...

https://github.com/stevepryde/tauri-yew-demo/blob/main/frontend/src/main.rs#L19

pub fn app() -> Html {
  let welcome = use_state_eq(|| "".to_string());
  let name    = use_state_eq(|| "Your_Name_Without_Spaces".to_string());

The name should NOT have any spaces because of this check...

https://github.com/stevepryde/tauri-yew-demo/blob/main/src-tauri/src/main.rs#L17-L18

fn hello(name: &str) -> Result<String, String> {
  if name.contains(' ') {
    Err("Name should not contain spaces".to_string())

Watch the process and result on Twitter...

https://twitter.com/MisterTechBlog/status/1483471147320500227

https://twitter.com/MisterTechBlog/status/1483300055171756032

(Yep building the Tauri + WebAssembly App on PinePhone is really slow, wish we could cross-compile on another computer and copy to PinePhone 🤔)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment