Darto
🎯 Darto Github
Minimal, fast and type-safe web framework for Dart — inspired by Express and Hono.
Everything flows through a single concept: Context.
📚 Official documentation: https://darto-docs.vercel.app/
Support 💖
If you find Darto useful, please consider supporting its development 🌟Buy Me a Coffee.🌟 Your support helps us improve the package and make it even better!
Installation
dependencies:
darto: ^1.2.0
Quick Start
import 'package:darto/darto.dart';
void main() {
final app = Darto();
app.get('/users/:id', [], (Context c) {
final id = c.req.param('id');
return c.ok({'id': id});
});
app.listen(3000);
}
Examples
Ready-to-run projects are available in the examples/ folder of the monorepo:
| Example | What it covers |
|---|---|
example_basic_routing |
Route params, wildcards, optional params |
example_group_routes |
Route groups, nested groups, standalone routers |
example_middleware_pipeline |
Middleware chaining, short-circuit, combine |
example_auth_jwt |
JWT middleware, sign/verify helpers, c.user |
example_middleware_validator |
zValidator — schema-driven validation with zard |
example_validator |
validator() + zard — full control over the error response |
example_context_usage |
Full Context API, c.req, state, headers |
example_response_helpers |
c.ok, c.json, c.html, c.binary, redirects |
example_error_handling |
app.onError, app.notFound, DartoError |
example_upload |
In-memory and streamed-to-disk file upload |
example_static_files |
Static file serving with darto_static |
example_view_engine |
Mustache templates with darto_view |
example_websocket |
WebSocket rooms + broadcast (WsHub), HTTP fanout |
example_session |
Cookie-based signed sessions |
example_logger |
Structured logging + request logger (darto_logger) |
example_proxy |
Reverse proxy, header overrides |
example_env |
.env loading with darto_env |
example_di |
Typed DI — providers, scopes, c.read (darto_di) |
example_cache |
Read-through cache with remember() (darto_cache) |
example_rate_limit |
Distributed rate limiting (darto_rate_limit) |
example_auth |
Password hashing + session auth + OAuth (darto_auth) |
example_mailer |
Sending email — SMTP / console (darto_mailer) |
example_jobs |
Background jobs + retries (darto_jobs) |
example_openapi |
OpenAPI 3.1 spec + Scalar docs (darto_openapi) |
example_full_integration |
Full app — auth, CORS, validation, WebSocket |