Densha
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.
Features
1. File-based Routing
Routes are automatically created based on your file structure:
// /pages/users/[id].rs gets mapped to /users/:id
pub async
// /api/users.rs gets mapped to /api/users
pub async
2. Flexible Rendering
Choose your rendering strategy per page:
// SSG
// SSR
pub async
// CSR
3. Rust-optimized Developer Experience
// Start your app with a simple builder pattern
4. Tech Stack Flexibility
Mix and match your preferred technologies:
new
.with_web_framework // Or Axum, Rocket
.with_database // Or Diesel, SQLx
.with_frontend // Or Yew, Dioxus
Installation
# Install the CLI tool
# Create a new project
# Start development server
Project Structure
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
Documentation
For full documentation, visit docs.densha.rs.
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.