
Leptos Has a Free API: Build Full-Stack Web Apps in Rust
What if your web framework had Rust's type safety, compiled to WebAssembly, AND had server functions like Next.js? Meet Leptos. What Is Leptos? Leptos is a full-stack web framework for Rust. It compiles to WebAssembly for the client and runs natively on the server. You get: Fine-grained reactivity (like Solid.js, not like React) Server functions (like Next.js server actions) SSR + hydration Type-safe routing Compile-time checking for everything The Syntax use leptos :: * ; #[component] fn Counter () -> impl IntoView { let ( count , set_count ) = create_signal ( 0 ); view! { < button on : click = move | _ | set_count .update (| n | * n += 1 ) > "Count: " { count } </ button > } } If you know React + Rust, you can read this immediately. The view! macro looks like JSX. Signals work like Solid.js. But it's all type-checked at compile time. Server Functions #[server(GetUsers)] pub async fn get_users () -> Result < Vec < User > , ServerFnError > { let users = sqlx :: query_as :: < _ , User >
Continue reading on Dev.to Webdev
Opens in a new tab



