Crates.io | densha |
lib.rs | densha |
version | |
source | src |
created_at | 2025-04-12 16:20:48.608703+00 |
updated_at | 2025-04-12 16:20:48.608703+00 |
description | A modern full-stack web framework for Rust |
homepage | |
repository | https://github.com/densha/densha |
max_upload_size | |
id | 1631062 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Next.js inspired Rust fullstack framework with file-based routing
Densha (電車, Japanese for "train") is a fullstack web framework for Rust that brings the developer experience of Next.js to the Rust ecosystem. It provides file-based routing, multiple rendering strategies (SSG, SSR, CSR), and a flexible adapter system for choosing your preferred tech stack.
Routes are automatically created based on your file structure:
// /pages/users/[id].rs gets mapped to /users/:id
#[page]
pub async fn user_page(Path(id): Path<String>) -> impl IntoResponse {
// Page component
}
// /api/users.rs gets mapped to /api/users
#[api]
pub async fn list_users() -> Json<Vec<User>> {
// API endpoint
}
Choose your rendering strategy per page:
#[page(render = "static")] // SSG
pub fn about_page() -> impl IntoResponse {
// Static page generated at build time
}
#[page(render = "server")] // SSR
pub async fn dashboard_page(State(db): State<Database>) -> impl IntoResponse {
// Server-rendered page at request time
}
#[page(render = "client")] // CSR
pub fn client_page() -> impl IntoResponse {
// Client-side rendered page
}
// Start your app with a simple builder pattern
fn main() {
Densha::new()
.with_database() // Automatic database setup
.with_hot_reload() // Hot reloading during development
.with_api_docs() // Automatic API documentation
.start()
}
Mix and match your preferred technologies:
Densha::new()
.with_web_framework(WebFramework::Actix) // Or Axum, Rocket
.with_database(Database::SeaOrm) // Or Diesel, SQLx
.with_frontend(Frontend::Sycamore) // Or Yew, Dioxus
# Install the CLI tool
cargo install densha-cli
# Create a new project
densha new my-app
cd my-app
# Start development server
densha dev
my-app/
├── Cargo.toml
├── src/
│ ├── main.rs # App entry point
│ ├── pages/ # Page components
│ │ ├── index.rs # Home page (/)
│ │ ├── about.rs # About page (/about)
│ │ └── users/
│ │ ├── index.rs # Users list page (/users)
│ │ └── [id].rs # User detail page (/users/:id)
│ └── api/ # API endpoints
│ └── users.rs # Users API (/api/users)
└── public/ # Static assets
For full documentation, visit docs.densha.rs.
MIT
Contributions are welcome! Please feel free to submit a Pull Request.