-
Notifications
You must be signed in to change notification settings - Fork 2
KoaJS
Koa.js is my favorite Node.js framework for building servers. It is developed by the same developer, TJ Holowaychuk, as the initial developer of one of the most popular node.js frameworks, Express.js. However, koa.js is created in a much modern way which was made available after the release of newer node.js versions.
I'm a fan of this repository, and use it in an almost daily basis, so I though why not make a documentation & review about it.
Creating a Hello World
server with koa.js
is as easy as below:
const Koa = require('koa');
const app = new Koa();
app.use(async ctx => {
ctx.body = 'Hello World';
});
app.listen(3000);
You should have node.js
(at least version 8) installed in your PC / MAC. If not, check out nvm to install it on UNIX systems or nvm-windows for Windows.
You can verify your node version via running node --version
in a terminal.
Koa.js is a slim framework providing an easy way to create node.js
servers. It's very similar to express.js
and lets you create a fully functional server by creating middlewares
.
There are lots of open source modules for adding & creating new middlewares, most populars listed on its Koa Wiki Page
It provides you all the benefits of the modern node.js but in a much less complicated manner.
Installing nvm
, node
, koa
and creating a simple hello world server from scratch with them, all combined takes around 5 to 10 minutes.
Afterwards, one can go through some of the tutorials in Koa.js Video Tutorials or Koa.js Tutorials about 1-2 hours to grasp the basics of how to create & run a koa.js server themselves.
Finally, after learning and getting used to it, one can make small servers in 30 minutes, or much bigger ones in weeks or months.
Koa.js
is a simple & small & fast node.js
framework, that's not hard to learn at first. Using the official Wiki Page, you can access lots of useful modules & tutorials to master the framework. But the best part of it is, that it can be used in both the simplest and the most complex projects perfectly.
I love the benefits of using koa.js
in my projects, but other than that; its website is koajs.com a single page app leading directly to its api documentation which is always concise and what's needed, it has a Wiki Page, providing useful links and references to great modules & tutorials while still being extremly concise (you don't have to navigate from page to page to find where the resources links / documentation are).