However, using Node on its own can be tricky. When I was first learning how to set up my server-side using Node, my friend gave me this advice: “First lesson in using Node – use Express. ” I was curious about what he meant, but forged forward, only to soon find myself in callback hell with a series of other issues.
Additionally, when using Node on its own, you have to worry about parsing POST requests in a certain way. Frameworks have many different modules you can choose from to simplify this process.
Express is a popular framework to use with Node. Honestly, once I started using Express I have never gone back to creating an app using just Node by itself – there are just too many benefits. Express makes routing, serving up your static files, and a host of other things super simple. For instance, you can require body-parser, a middleware that helps you take care of parsing data easily.
Koa differs from Express because it uses generator functions, a feature in ES6 that I happen to like a lot! Interestingly, the people who are behind Koa are the same people that made Express, and they set out to make a tool that would make creating the server side your app even easier. Anything you can do with Express you can do with Koa, but getting used to generator functions their syntax can take a little time.
I’m realizing as I’m writing this that this blog post should/could actually be turned into about three or four posts specifically introducing Express and Koa specifics.
TL;DR: Simplify your life by using Express or Koa when using NodeJS.