If you are reading this article, you may be interested in Node.js or backend development or both. This article aims to introduce you to what you can do with Node.js in backend (or server-side) development. By the end of this article, you will have built a simple server that runs on your computer using Node.js.
This article is easier to follow if you understand JavaScript. You will need a code editor like VSCode or Sublime Text to write code to build the server.
What is Backend Development?
Backend development involves writing programs that run on servers. A server is a computer that accepts requests from other computers (called clients) and executes them. A request might ask the server to
- respond with a file from its file system,
- respond with information from a database,
- modify data in a database,
- transfer information from the server to another server
Backend development involves writing programs that run on servers to handle these requests.
Servers do not have a graphical user interface (GUI) with icons and buttons for instructing a computer like phones and laptops do. Instead, servers are instructed by entering code commands in a terminal or executing code written in files.
Node.js for Backend Development
JavaScript was not intended for writing programs that run on the server. It was built to run in web browsers. Node.js provides an environment that enables JavaScript to run outside a web browser.
For example, JavaScript does not have the ability to modify the files on a computer by itself and this is an important part of backend development. Node.js enables JavaScript to modify files among other things.
Installing Node.js
To get started with Node.js, download it and install it on your computer. Your computer will use Node.js to execute JavaScript without needing a browser. Visit the Node.js download page and you will see a section of the page similar to the image below.

Download and install Node.js by
- Selecting your preferences from the four dropdowns on the download page
- Copying the instructions to your clipboard by clicking “Copy to clipboard”
- Pasting the instructions in a terminal on your computer and running it
This method makes it easier to upgrade your Node.js version in the future compared to downloading and installing the prebuilt binary.
Building a Simple Server
Using Node.js, you can create a simple web server that listens for requests from clients and responds with data. The example below walks you through building a simple web server that responds with HTML content.
To create the web server, follow the steps below:
- Create a folder on your computer. You can name the folder “simple-nodejs-server”
- Open the folder in VSCode or Sublime Text
- Create a file with the name “index.js” in the folder
- Copy and paste the code snippet below into index.js
const { createServer } = require("node:http");
const url = require("url");
const server = createServer(function (req, res) {
const query = url.parse(req.url, true).query;
const html = `<section>
<h1>A Simple Web Server with Node.js</h1>
<p>This HTML is coming from a simple web server created with Node.js</p>
<p> - ${query.username}
</section>`;
res.writeHead(200, { "Content-Type": "text/html" });
res.end(html);
});
server.listen(3000, function () {
console.log("Listening on port 3000");
});
- Open a terminal in the project folder and execute index.js with the command node index.js. You should see the text “Listening on port 3000” on the terminal
- Using any web browser of your choice, visit localhost:3000?username=Jake. You would see the result in the image below in the web browser.

To stop the server, click on the terminal that you used to run the file and use the Ctrl + C key combination.
Understanding the Code
In the code snippet, createServer is used to create a server. The createServer function accepts two arguments - req and res. req holds data about the incoming request from a client and res contains methods and fields that are used to construct a response and respond to the client.
url.parse is used to get the username query parameter from the request. The value of username is attached to the HTML string which is sent back as a response to the client using res.end. res.writeHead is used to set the status code (200) and the content type (text/html) of the response for use by the client. You can change the value of the username query parameter to “Sam” via the URL to see the result.
What’s Next?
The example above is simple and shows how Node.js can be used to create a server. You may want to consider adding more features to the server on your own to understand better by doing. Some feature suggestions include
- creating another route that responds with the content of a file on the server
- creating a POST route that accepts JSON in the body of the request, modifies it and returns it
Once you are comfortable, explore frameworks like Express, NestJS and AdonisJS to build more advanced backends.
Frequently Asked Questions
What is Node.js and why is it used for backend development?
Node.js is a JavaScript runtime that allows you to execute JavaScript outside of a browser environment. It does this by building APIs around the core V8 engine that makes JavaScript run in the browser. It is popular for backend development because of its non-blocking, event-driven architecture and its ability to handle many simultaneous connections efficiently.
What are the prerequisites to learning Node.js for backend development?
To learn Node.js for backend development, you should be familiar with
- basic JavaScript syntax, including callbacks, promises and async/await
- an understanding of HTTP and REST APIs
- basic command line usage
What kind of applications is Node.js best suited for?
Node.js is ideal for applications that are event-driven i.e applications that listen for events and react to them. The types of applications that will work well when built with Node.js include:
- Streaming applications e.g Netflix and Spotify
- Real-time applications e.g chat applications, real-time games, real-time analytics applications like weather reporting applications
- Internet of Things applications

Orim Dominic Adah
Orim Dominic Adah is a web developer and a technical writer with more than four years of experience. He is focused on building functional, maintainable software that delivers business value.
Article by Gigson Expert