In this example, I am going to create an example for how to show Number of visits in Node.Js.

Number of Visits in Node.js:

Here I am going to show how to show Number of Visits in Node.js.

First of all, create a js file at any location with the name CounterExample.

Write the following code in CounterExample.js file.

var http = require('http');

var VisitCount = 0;

http.createServer(function (request, response) {

console.log('Connecting to Server');


response.writeHead(200, {'Content-Type': 'text/plain'});

response.write('Welcome to Node.Js tutorial!\n');

response.write('Total Visits'+VisitCount+' \n');



console.log('Server started run at the http://localhost:3000');

Now open Node.Js command prompt and switch to your CounterExample.js file location and run the following command.

Node CounterExample.js

Number of Visits


Number of Visits

Every time you refresh the page the Number of visits will increase.

View More:


I hope you loved this post. Your feedback, comments, and suggestions are always welcome to me.

Thank You.


  • Simply desire to say your article is as amazing. The clearness on your submit is simply great and i can assume you’re knowledgeable in this subject. Fine with your permission let me to clutch your feed to stay updated with imminent post. Thank you 1,000,000 and please carry on the gratifying work.

  • Thank you for all of your efforts on this blog. Ellie take interest in making time for research and it’s really easy to see why. A lot of people hear all concerning the powerful medium you convey very helpful guidance through the website and in addition boost contribution from some other people on this area of interest and our own princess has always been learning a lot of things. Take advantage of the rest of the new year. You have been conducting a pretty cool job.