Densha 🚀
A Next.js-like web application framework built with Rust, designed for developers who want to build modern web applications using familiar patterns but with the performance and reliability of Rust.
Features
✨ File-based Routing - Create pages and API routes with simple file structure 🎨 Component-based Architecture - Write components in Kotoba syntax ⚡ Fast Development - Hot reload and instant feedback 🔧 Full-stack Ready - Handle both frontend and backend in one place 📦 Zero Configuration - Get started immediately with sensible defaults
Quick Start
# Install Densha CLI
# Create a new project
# Start development server
Project Structure
my-app/
├── app/ # Page components (file-based routing)
│ ├── page.kotoba # Home page (/)
│ ├── layout.kotoba # Root layout component
│ ├── globals.css # Global styles
│ └── about/
│ └── page.kotoba # About page (/about)
├── api/ # API routes (serverless functions)
│ └── hello/
│ └── route.kotoba # API endpoint (/api/hello)
├── public/ # Static files (served at /)
│ └── globals.css # Additional global styles
├── styles/ # Component-specific styles
└── densha.json # Project configuration
Writing Pages
Create pages in the app/ directory using Kotoba syntax:
// app/page.kotoba - Home page
export default
Creating API Routes
Define serverless functions in the api/ directory:
// api/hello/route.kotoba
export
export
File-based Routing
| File Path | Route | Example |
|---|---|---|
app/page.kotoba |
/ |
Home page |
app/about/page.kotoba |
/about |
About page |
app/blog/[slug]/page.kotoba |
/blog/:slug |
Dynamic route |
api/users/route.kotoba |
/api/users |
API endpoint |
Available Scripts
densha dev- Start development server with hot reloaddensha build- Build application for productiondensha start- Start production serverdensha export- Export to static filesdensha init- Create a new project
Templates
Densha comes with several project templates:
default- Basic setup to get you startedblog- Blog functionality with dynamic routingapi- API-focused project with documentationfullstack- Complete application with pages and API routes
# Create a blog project
# Create an API project
Architecture
Densha is built on top of:
- Hyper - Fast HTTP server
- Tokio - Async runtime
- Handlebars - Template rendering
- Serde - Serialization
- Tower - Middleware framework
Contributing
We welcome contributions! Please see our Contributing Guide for details.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
at your option.
Support
Built with ❤️ using Rust