Introduction to Koa Js

What is koa js?
Koa.js is a flexible Node.js web application framework that provides robust web and mobile application features. Koa.js is a lightweight framework for building web apps and APIs. The framework’s features and technologies help programmers simplify the creation of web apps and APIs.
Let’s create a sample project using Koa.js
- Before we start to develop, we need to have installed Node and npm. Using this link we can install Node.js, https://nodejs.org/en/download/

Node Package Manager (npm)
- npm is a package manager for node. The npm registry is a public library of open-source code packages for Node.js, front-end websites, mobile apps, robots, routers, and a variety of other JavaScript needs. npm gives us access to all of these packages and allows us to install them locally.

- Using the following command you can check the installed version on node and npm.
> node --version
> npm --version
- You will get output like this,

Let’s go on the step by step.
Step 1:
- Here I used vs code to run this program. Create a new folder named hello-world.

Step 2:
- Open new ‘Terminal’ and run the following code to create a package.json file,
npm init
- It will request the following information from you.

Step 3:
- To install koa run the following code,
npm install koa
- To install nodemon run the following code,
npm install nodemon --save-dev
Step 4:
- Create a new file called app.js and type the following code,
var koa = require('koa');
var app = new koa();
app.use(function* (){
this.body = 'Hello world!';
});
app.listen(3000, function(){
console.log('Server running on https://localhost:3000')
});
- Save the file and type the following code in terminal,
nodemon app.js
- This will start the server. To test this app, go to https://localhost:3000 in your browser and you should see the following message.

Hope you learned something from this article.
Thank you!