Serverpod vs Shelf
Serverpod and Shelf provide two options for building a Dart backend. Either through a full framework with a generated client or a minimal HTTP toolkit that you extend yourself.
Serverpod vs Shelf at a glance
Both run Dart on the server. The difference lies in scope: Shelf provides the HTTP layer, while Serverpod offers the full backend.
| Capability | Serverpod | Shelf |
|---|---|---|
| Language | ✓ Dart on the server and the client | ✓ Dart on the server |
| Type safety | ✓ End-to-end, checked at compile time | ✗ Manual, JSON encoded by hand |
| Generated client | ✓ Generated from your endpoints | ✗ Manual, hand-written HTTP calls |
| Middleware | ✓ On the built-in web server | ✓ Composable handler pipeline |
| Database | ✓ PostgreSQL with a type-safe ORM | ✗ External package needed |
| Authentication | ✓ Email, social sign-in, and passkeys | ✗ External package or manual |
| Real-time | ✓ Typed WebSocket streams | ✓ Through shelf_web_socket, untyped |
| Background work | ✓ Future calls and cron tasks | ✗ External package needed |
| Hosting | ✓ Docker anywhere, or Serverpod Cloud | ✓ Anywhere Dart runs |
| Open source | ✓ BSD-3 packages, SSPL server | ✓ BSD-3, from the Dart team |
What is Shelf?
Shelf is the Dart team’s model for web server middleware, built around composable handlers. It is deliberately minimal: a request goes into a function, and a response comes out. Much of the Dart server ecosystem builds on it, including Dart Frog.
What is Serverpod?
Serverpod is an open-source backend framework for Flutter and Dart. You write endpoint methods in plain Dart, and Serverpod generates a type-safe client for your app. The database ORM, authentication, streaming methods, and task scheduling are part of the framework.
How they compare
The real decision is how much of the backend you want to build by hand. Shelf handles HTTP and deliberately stops there. Serverpod starts at HTTP and keeps going.
Web server or backend framework
Shelf provides handlers, middleware, and adapters, leaving the rest to other packages or your own code. That is a design goal, not a gap. Serverpod covers the same HTTP layer and adds the next parts most apps need: a database, authentication, real-time streams, and scheduled work.
Routing and middleware
With Shelf, you compose a pipeline of middleware and route requests with shelf_router. In Serverpod, an endpoint method is a route, and the built-in web server adds conventional routes and middleware for webhooks, server-rendered pages, and static files.
REST APIs without hand-written JSON
A Shelf handler parses the request, runs your logic, and encodes the response by hand.
final router = Router()
..get(
'/users/<id>',
(Request request, String id) async {
final user = await findUser(int.parse(id));
return Response.ok(jsonEncode(user.toJson()));
},
);
A Serverpod endpoint method is the API. The parsing, serialization, and client are generated.
class UserEndpoint extends Endpoint {
Future<User?> getUser(Session session, int id) async {
return User.db.findById(session, id);
}
}
Your Flutter app calls it as a method: final user = await client.user.getUser(1);
Database, authentication, and background work
On Shelf, you choose a Postgres driver, an ORM, an authentication solution, and a job runner, and wire them together yourself. Serverpod ships them as one system: a type-safe ORM on PostgreSQL with migrations, sign-in with email, social providers, and passkeys, and future calls with cron-style recurring tasks.
Running a production backend
Production needs health checks, structured logging, tests, and a deployment story. Serverpod includes all of them out of the box: built-in health checks, a logging system with its own viewer, a testing framework that boots a real server, and a Docker setup in every project. Production Dart services do run on plain Shelf, but each of these pieces is yours to assemble and maintain.
Pricing
Both are free and open-source, so the cost comparison is in engineering time. With Shelf, you pay for the surrounding backend in the parts you build and maintain. Serverpod is free to self-host, and Serverpod Cloud offers flat monthly tiers from $19 per month.
Migrating from Shelf
A Shelf server and a Serverpod server can run side by side, so you can move one route group at a time. Handlers that return JSON become endpoint methods, and your hand-written Flutter networking code is replaced by the generated client. Middleware concerns, such as logging and authentication, map to features Serverpod already provides.
Keep your Shelf service running and move one feature to Serverpod first. The generated client makes the Flutter side of the move mostly deletion.
Everything you get with Serverpod
Why teams choose Serverpod
Frequently asked questions
Is Serverpod a Shelf alternative?
Yes, for building a full backend. Serverpod is a backend framework that includes a database, authentication, and a generated client, while Shelf is a minimal HTTP toolkit that you extend with your own choices.
Can I migrate a Shelf server to Serverpod?
Yes. Both are Dart, so your business logic carries over. Handlers become endpoint methods, and the two servers can run side by side while you move routes incrementally.
Does Serverpod support middleware?
Yes. Serverpod’s built-in web server supports routes and middleware for HTTP concerns, such as webhooks and server-rendered pages. API endpoints handle authentication and access control through framework features, such as requireLogin and scopes.
Can Shelf run a production backend?
Yes, and production Dart services do. The difference is that with health checks, logging, authentication, and background work, you assemble them yourself, whereas Serverpod includes them.