🦀 Leptos WASI Component Template

License: MIT Rust: 1.82+ Leptos WASI

A production-ready cargo-generate template for creating full-stack Rust web applications using Leptos framework with WebAssembly System Interface (WASI) Components. This template provides a complete, working setup for server-side rendered (SSR) Rust web applications with client-side hydration, ready for deployment on any WASI-compatible runtime.

Note:
The default branch/tag (0.1.3) is pinned to match a specific leptos_wasi version.
Using main or newer tags may introduce breaking changes unless you explicitly opt into them.


🚀 Quick Start

Install cargo-generate:

cargo install cargo-generate

Generate a new project using the stable release:

cargo generate --git https://github.com/codeitlikemiley/leptos-wasi-template --name counter -s

Generate from a specific version:

cargo generate --git https://github.com/codeitlikemiley/leptos-wasi-template --branch 0.1.3 --name counter -s

🌟 Features

  • WASI Component Architecture – Full Guest trait and WasiExecutor implementation
  • Server-Side Rendering (SSR) – Fast initial page loads
  • Client-Side Hydration – Interactive UI with seamless hydration
  • Server Functions – Type-safe RPC between client and server
  • File-Based Routing – Automatic routing for organized pages
  • Static Asset Serving – Built-in support for WASI filesystems
  • Tailwind CSS Support – Pre-configured and ready to use
  • Working Counter Example – Demonstrates full client-server flow

📋 Prerequisites

  • Rust 1.82+

  • WASI Target:

    rustup target add wasm32-wasip2
  • cargo-generate:

    cargo install cargo-generate
  • cargo-leptos:

    cargo install cargo-leptos
  • Wasmtime CLI:

    cargo install wasmtime-cli
  • (Optional) Tailwind CSS:

    npm install -g tailwindcss

🛠️ Build and Run

cd my-app
cargo leptos build --release
chmod +x serve.sh
./serve.sh

Access your app at http://localhost:8080.


📁 Project Structure

my-app/
├── Cargo.toml
├── README.md
├── serve.sh
├── public/
│   └── favicon.ico
└── src/
    ├── main.rs
    ├── lib.rs
    ├── server.rs
    ├── routes.rs
    └── pages/
        ├── mod.rs
        └── home.rs

📄 License

This template is dual-licensed under MIT or Apache 2.0. Generated projects are free to adopt their own licensing.


🗂 Versioning

Each template tag corresponds to a specific leptos_wasi version to ensure compatibility. Check the available versions:

git ls-remote --tags https://github.com/codeitlikemiley/leptos-wasi-template