Update: (May 8, 2019) A previous version of this article included Rikulo Stream, but I removed it since it didn’t seem like it was being actively developed. Also, I am changing the Shelf section to be more generally about server products from the Dart Team.
Update: (December 2019) Updated stats and links.
If it weren’t for Flutter, I wouldn’t even have considered Server Side Dart. But the same thing that made me choose Flutter, now has me pursuing building the backend with Dart.
I eagerly embraced Flutter because I was frustrated with how long it was taking me to build two separate apps for Android and iOS. How wonderful to just have just one code base for both! And now we can have the same Flutter app written in Dart work on the desktop and web as well. Why wouldn’t I want to extend this to the server backend?
I know that there is an advantage in being a polyglot, and programming languages are much faster to learn than human languages, but still, it takes time. I don’t want to think about how to write the syntax when I am trying to implement a feature. I just want to effortlessly write it out. That doesn’t happen when I am constantly having to switch languages and learn new ones. If I could use Dart when I write Android apps and Dart when I write iOS apps and Dart in the browser and Dart on the desktop…and Dart on the server, I would be a very happy developer indeed.
So that’s why I chose Dart.
In case you didn’t know, Dart isn’t actually very popular as a server backend language. Yet. But I’m expecting Flutter to only increase in popularity, and with that I think other people like me are going to see the attractiveness of extending the one-language concept to the backend.
The question now is choosing the framework to use in Dart. Of course, you could write everything yourself using the
dart:html libraries or the
http package, but there are a lot of common tasks (like authentication, validation, and database management) that have already been solved elsewhere. Using a framework for those tasks will save a lot of unnecessary work.
My main criteria for choosing a framework is popularity, reliability and usability.
- Popularity: The more popular a framework is, the more likely it is to be maintained and the more likely I am to find other people to help me with my questions.
- Reliability: I don’t want to spend time learning a framework if the developers are going to stop maintaining it. There are a number of Dart server frameworks that were popular a few years ago (like Redstone), but are no longer being maintained today.
- Usability: By this I mostly mean good documentation, good examples, and good places to find answers to my questions.
Of course, it would be nice to also have good performance, but at this point I will leave the benchmark tests to someone else and assume they all perform the same. (When you’ve written that article, leave me a link in the comments.)
I reviewed a number of Dart server frameworks and came out with four that are still being maintained and popular enough to consider. I will present them below in order of their popularity (based on GitHub stars).
I imagine that some day the developers of these frameworks may read this article, so I will also include a bit of unsolicited advice at the end of each section. Take it or leave it, but feel free to comment below.
From the official website:
Aqueduct is an extensible HTTP framework for building REST APIs on top of the Dart VM. It includes a statically-typed ORM, OAuth 2.0 provider, automated testing libraries and OpenAPI 3.0 integration.
- GitHub stars: 1408
- Pub popularity: 93
- Stack Overflow questions: 82
Based on GitHub stars, this is by far the most popular framework of the four that I am reviewing.
Aqueduct is a product of Stable Kernel, a company based in Atlanta, Georgia. Based on their about page, it looks like they have a good sized team. That makes me believe that Aqueduct should be reliably supported going forward.
Looking at the GitHub contributors list, the company CEO, Joe Conway, appears to be doing almost all of the development of Aqueduct himself (assuming that he was probably the stablekernal-admin user prior to 2017):
He is also the main person answering Aqueduct related questions on Stack Overflow and Slack. Having asked a few questions myself, he is very helpful, but ideally I’d like have the reliability of the framework not be based on just one person.
The Aqueduct documentation is very thorough. It comes complete with explanations, tutorials, guides, and examples. Most other questions I’ve had I’ve been able to get answered in Stack Overflow and Slack.
From my perspective, Aqueduct seems to be built as a unified whole. When you choose it you get the whole thing. For example, Aqueduct’s ORM is tightly linked to PostgreSQL. That probably makes it easier to use, but I’m also attracted to what appears to be the more modular approach in the Angel framework (see below).
Suggestion to the developers
Joe Conway, with your responsibilities as CEO, maintaining Aqueduct, and answering questions on Stack Overflow and Slack, I’d hate to see you get burnt out. One option could be tasking some of your company employees to take over some of the development and question load.
In the words of the developer, Angel is
A polished, production-ready backend framework in Dart.
With features like hot reloading 🔥, GraphQL, and ORM, Angel is the perfect Dart backend to power production apps. Angel also provides support for server-side templating, WebSockets, authentication, and much, much more.
With over 3 dozen official extension packages and counting, and the flexibility to easily add functionality, Angel has all the tools you need to build an application of any size. Angel is designed with extensibility in mind, so even when you need a feature that’s not officially supported, you can easily implement it yourself.
- GitHub stars: 705
- Pub popularity: 87
- Stack Overflow questions: few
This is a strong second for popularity, though there doesn’t seem to be much activity on Stack Overflow. The popularity and maintenance are strong on Pub, which is good to see.
The developer, Tobe Osakwe, is a college student at Florida State University. This is quite an impressive side project for a college student.
Although maintaining steady and active development, Tobe is the only main contributor to the GitHub repo:
There isn’t any indication that Tobe is going to stop maintaining this framework, but after he graduates from university, will his getting a job cause this framework to go to the wayside?
The documentation is well made. There are lots of explanations, guides, examples, and even YouTube tutorials (spoken in clear, easy to follow English).
Even if you don’t end up using this framework, you should definitely read Tobe’s blog article Deploying Dart Apps to Linux for when you are ready to put your server in online. It talks about how to secure your Dart app behind an NGINX proxy.
Suggestion to the developer
I’m impressed with your work and the Angel framework, Tobe Osakwe. I can see it having the potential to become the most popularly used Dart server backend. The only thing that is making me hesitate is the stability question: will you (or others) still be maintaining it in five years? If you can figure out a way to turn it into a profitable startup or to get the community involved in the development process, that would go a long way in reassuring people that investing the time to learn the framework is worth it. Also, dropping the emoji scattered across the official site would make it look more professional (but that’s just my opinion).
In the words of the GitHub wiki:
Jaguar is a batteries included, production ready HTTP server framework that is fast, simple and extensible.
- GitHub stars: 204
- Pub popularity: 82
- Stack Overflow questions: few
This framework has two authors: Ravi Teja Gudapati and Kevin Segaud. Most of the recent development work was done by Ravi, who is in Stockholm.
It appears to be a personal side project since the developer says he works for ABB. The development itself appears to be steady (although not much in the second half of 2019).
There is little happening on Stack Overflow, but the Gitter community is active and looks like a good place to get your questions answered.
One thing I like about this framework is how modular the library is. I first came across it when I was looking for a JWT library and found jaguar_jwt. So even if you don’t end up using the whole web framework, you can use smaller pieces of it without depending on everything else.
Suggestion to the developers
Probably the main thing is improving the documentation. It would be nice to see more guides and tutorials. Also, if you find yourselves answering the same questions repeatedly on Gitter, you might consider answering them on Stack Overflow so that they are searchable.
Dart Team (Shelf and other stuff)
The Dart Team has made quite a lot that you can build servers with. In fact, the three frameworks that we looked at above are all written with the lower level Dart code.
You don’t need to use a framework. You can build your own server using only the standard Dart libraries. Check out the following links to get started:
There is a package by the Dart Team called http_server, but it is not popular or well documented so I will not cover it here. I will cover the Shelf framework, though.
The GitHub page calls Shelf a web server middleware for Dart. The description says:
Shelf makes it easy to create and compose web servers and parts of web servers. How?
- Expose a small set of simple types.
- Map server logic into a simple function: a single argument for the request, the response is the return value.
- Trivially mix and match synchronous and asynchronous processing.
- Flexibility to return a simple string or a byte stream with the same model.
- GitHub stars: 172
- Pub popularity: 97
- Stack Overflow questions: 22
Although the GitHub score is the lowest of the frameworks I reviewed, the Pub popularity is the highest. It’s unclear what that means.
This framework is a package by the Dart Team, so it wins the prize for most likely to be maintained. It was mostly written by Kevin Moore and Natalie Weizenbaum of Google, with Kevin the only one currently maintaining it.
Unlike what we normally see with Flutter and Dart, the documentation is pretty sparse here. It looks like you can get help on Stack Overflow, but I don’t see any other obvious sources of help.
Since it is called “middleware”, it’s unclear to me whether I can use it as a full-fledged backend server, or if I need to combine it with other packages. I’m guessing that would be the standard HTTP communication libraries and perhaps the http_server package, but the guidance isn’t clear.
I first heard about Shelf when I was creating a library package. It was billed as a model example of how a Pub package should organize its files.
I get the idea that Shelf is a hidden treasure, but the documentation isn’t doing it any favors.
Suggestion to the developers
Give Shelf the same documentation love that the rest of Dart and Flutter has been given. Until that happens it’s not likely to be widely adopted. Also, update the general server code lab to be Dart 2 compliant.
I previously had done some exploratory development with Aqueduct, but I didn’t want to go any further if there were better options. Coming out of this review I feel confident in continuing to use Aqueduct. However, if you choose Angel or Shelf, I don’t think you’ll go wrong. I’m starting to doubt Jaguar, though. (In months since I wrote the original article, the popularity of Aqueduct and Angel have increased noticeably with regard to GitHub stars, Jaguar and Shelf not so much.)
If you want to maximize your learning, I suggest you start building a basic server by working through the Server Side Dart documentation from the Dart Team, and then going on to one of the bigger frameworks. I have also started a video tutorial series on Aqueduct which you can find here.
Feel free leave your comments below. If there is continued interest, I’ll try to keep this page updated.