百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
W

webapp.rs

> 前端框架
开源

一个完全使用 Rust 编写的 Web 应用程序。

2.2K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个完全使用 Rust 编写的 Web 应用程序。

# webapp.rs ## A web application completely written in Rust Target of this project is to write a complete web application including backend and frontend within Rust. ```mermaid graph LR A[Leptos / WASM
in browser] -->|SSR / RPC| B[Axum
HTTP Server] B --> C[SQLx] C --> D[(PostgreSQL)] ``` ### Blog Posts 1. [A Web Application completely in Rust](https://medium.com/@saschagrunert/a-web-application-completely-in-rust-6f6bdb6c4471). 2. [Lessons learned on writing web applications completely in Rust](https://medium.com/@saschagrunert/lessons-learned-on-writing-web-applications-completely-in-rust-2080d0990287). ## Architecture | Component | Technology | |-----------|------------| | Frontend | [Leptos](https://leptos.dev) (WebAssembly with SSR + hydration) | | Backend | [Axum](https://github.com/tokio-rs/axum) (via leptos_axum) | | Database | [PostgreSQL](https://www.postgresql.org) (via SQLx) | | Auth | JWT tokens (jsonwebtoken) + Argon2 password hashing | The application uses Leptos server functions to communicate between frontend and backend, eliminating the need for a separate REST API layer. Both server and client are compiled from a single Rust crate. ## Features - User registration with Argon2 password hashing - Login with username and password - JWT-based session management with automatic renewal - PostgreSQL session and user storage - CSRF protection via origin validation - Health check endpoint (`/healthz`) for container orchestration - Server-side rendering with client-side hydration - Single binary deployment ## Prerequisites - [Rust](https://rustup.rs) (stable) - [cargo-leptos](https://github.com/leptos-rs/cargo-leptos): `cargo install cargo-leptos` - [PostgreSQL](https://www.postgresql.org) - `wasm32-unknown-unknown` target: `rustup target add wasm32-unknown-unknown` - [wasm-bindgen-cli](https://rustwasm.github.io/wasm-bindgen/): `cargo install wasm-bindgen-cli` ## Getting Started Start a PostgreSQL instance: ```sh docker run -d --name postgres \ -e POSTGRES_USER=webapp \ -e POSTGRES_PASSWORD=webapp \ -e POSTGRES_DB=webapp \ -p 5432:5432 \ postgres:17 ``` Run the application: ```sh export DATABASE_URL=postgres://webapp:webapp@localhost/webapp cargo leptos watch ``` The application will be available at `http://127.0.0.1:3000`. Register a new account using the "Register" link on the login page, then log in with your credentials. ## Configuration | Environment Variable | Description | Default | |---------------------|-------------|---------| | `DATABASE_URL` | PostgreSQL connection string | `postgres://localhost/webapp` | | `JWT_SECRET` | Secret key for JWT token signing | `change-me-in-production` | | `LEPTOS_SITE_ADDR` | Server listen address | `127.0.0.1:3000` | ## Container Build and run as a container: ```sh docker build -t webapp . docker run -p 3000:3000 \ -e DATABASE_URL=postgres://webapp:[email protected]/webapp \ webapp ``` ## Development ```sh cargo fmt --check # Check formatting cargo clippy --features ssr -- -D warnings # Lint server code cargo test --features ssr # Run tests cargo leptos build # Build for development cargo leptos build --release # Build for production ``` ## Contributing You want to contribute to this project? Wow, thanks! So please just fork it and send me a pull request. ## License [Apache 2.0](LICENSE)

GitHub Issues· 0 开放

在 GitHub 查看全部

暂无开放 Issues,或尚未同步最近议题。

核心特点

  • •User registration with Argon2 password hashing
  • •Login with username and password
  • •JWT-based session management with automatic renewal
  • •PostgreSQL session and user storage
  • •CSRF protection via origin validation
  • •Health check endpoint (/healthz) for container orchestration
  • •Server-side rendering with client-side hydration
  • •Single binary deployment
  • •Rust (stable)
  • •cargo-leptos: cargo install cargo-leptos

> 标签

Rustactix-webbackenddieseldiesel-rs

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架