A modern full-stack web application built with Rust, Leptos, and WebAssembly (Wasm). This project demonstrates how to build high-performance web applications by compiling Rust to WebAssembly, combining the speed of native code with the reach of the web.
my_first_rust_app/
├── ui-components/ # UI Component Library (compiles to Wasm)
│ ├── src/
│ │ ├── components/ # Reusable UI components
│ │ ├── layouts/ # Layout components
│ │ ├── theme/ # Theme system and providers
│ │ └── styles/ # Tailwind CSS styles
│ ├── package.json # Node dependencies for Tailwind
│ └── tailwind.config.js
│
├── frontend/ # Main Application (compiles to Wasm)
│ └── src/
│ ├── features/ # Application features
│ └── services/ # API and business services
│
└── backend/ # Backend Server (native Rust)
cargo install trunk
) - for building and bundling Wasmrustup target add wasm32-unknown-unknown
)cargo install wasm-bindgen-cli
) - for Wasm bindingsInstall Dependencies:
# Install Rust dependencies
cargo build
# Install UI library dependencies
cd ui-components
yarn install
Start Development Servers:
In separate terminal windows:
# Terminal 1: Start the backend server
cd backend
cargo run
# Terminal 2: Watch and compile Tailwind CSS
cd ui-components
yarn watch:css
# Terminal 3: Start the frontend development server
cd frontend
trunk serve --port 3000
The application will be available at:
UI Components:
ui-components/src/components/
Theme Development:
ui-components/src/theme/themes/
Frontend Features:
frontend/src/features/
frontend/src/services/
Backend Development:
backend/src/
The application includes a robust theme system that supports:
Theme variables available:
--background /* Background color */
--surface /* Surface/card color */
--text /* Primary text color */
--text-muted /* Secondary text color */
--primary /* Primary brand color */
--secondary /* Secondary brand color */
--accent /* Accent color */
--primary /* specific primary */
--secondary /* specific secondary */
--accent /* specific accent */
# Build the UI components
cd ui-components
yarn build:css
# Build the frontend
cd frontend
trunk build --release
# Build the backend
cd backend
cargo build --release
The application works best in modern browsers that support:
Note: Some browser console warnings about subresource integrity for preloaded resources are expected in Chrome and can be safely ignored.