Server-Side Dart
44.1 shelf (Composable HTTP Middleware)
import 'dart:convert';
import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart' as io;
import 'package:shelf_router/shelf_router.dart';
final _todos = <Map<String, dynamic>>[];
Router buildRouter() => Router()
..get('/health', (Request req) => Response.ok('ok'))
..get('/todos', (Request req) => Response.ok(jsonEncode(_todos), headers: {'content-type': 'application/json'}))
..post('/todos', (Request req) async {
final body = jsonDecode(await req.readAsString()) as Map<String, dynamic>;
final todo = {'id': _todos.length + 1, 'title': body['title'], 'done': false};
_todos.add(todo);
return Response(201, body: jsonEncode(todo), headers: {'content-type': 'application/json'});
})
..get('/todos/<id|[0-9]+>', (Request req, String id) {
final todo = _todos.where((t) => t['id'] == int.parse(id)).firstOrNull;
return todo == null ? Response.notFound('Not found') : Response.ok(jsonEncode(todo));
});
Future<void> main() async {
final handler = const Pipeline()
.addMiddleware(logRequests())
.addHandler(buildRouter().call);
final server = await io.serve(handler, '0.0.0.0', 8080);
print('Serving at http://${server.address.host}
…44.2 Frameworks
Dart Frog (Very Good Ventures) Fast, minimalistic backend framework with file-based routing, middleware, hot reload, DI via providers
Full-stack Dart backend: ORM (PostgreSQL), code-generated client for Flutter, auth, caching, streaming, Serverpod Cloud
shelf + shelf_router / shelf_static / shelf_web_socket Dart team's composable building blocks
Serverpod's modern web server foundation Alfred, Conduit (community) Express-like / full-featured
functions_framework (Cloud Functions/Run), googleapis packages
44.3 Databases and Backend Services
postgres (the PostgreSQL driver), mysql_client, sqlite3 (FFI), drift (type-safe SQL, also for Flutter), mongo_dart, redis, Firebase (via the Admin REST APIs / dart_firebase_admin), Supabase (supabase package), Appwrite.
Deployment: compile to a native executable (dart compile exe) in a small Docker image (FROM dart:stable AS build → FROM scratch + runtime libs), Cloud Run, Fly.io, Railway, Kubernetes.