Introduction to Web Programming in Node

What is web programming in Node.js and how does it work?

Scroll down...




Welcome to the beginning of web development with Node.js! This is where things really start to get exciting. This is where we begin to move away from command-line apps in Node.js and start to focus on Node's true purpose: to create web applications.

Server and Client

You've no doubt heard of a server and client. In the upcoming lesson, we will clarify the relationship between the server and client and the details of how information is passed between them. We'll cover the details of what a web server actually is and how a web application works with a web server. We'll also clear up some of the terminologies like IP address, port, and sockets along the way.


HTTP is the foundation of data communication for the World Wide Web.

HTTP is a protocol or set of rules that all web applications, clients, and servers can understand. The standardization of HTTP makes it possible for these different technologies to communicate regardless of the language in which they're written. We'll cover the basics of HTTP and how it works so that when you dive into using Node's HTTP library you're fully aware of what is happening under the hood.

Serving with Node

As an asynchronous, event-driven JavaScript runtime, Node is designed to build scalable network applications.

Node was built to serve. This is readily apparent when navigating to the about page of the Node.js website and the first thing you see is an example server:

const http = require('http');

const hostname = '';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World\n');

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);

We'll be walking you through how to set up a server in Node.js as well as how to use the HTTP library to receive client requests and respond to them with HTML documents.

Wrapping Up

The most popular web frameworks in Node.js all come down to the nuts and bolts that you are about to learn. Once you understand these details and are able to work with HTTP in Node at a lower level, the frameworks that you use later will make that much more sense and be that much easier to leverage.

Sign up to track your progress for free

There are ( ) additional resources for this lesson. Check them out!

There are no additional resources for this lesson just yet!

Sorry, comments aren't active just yet!

Next Lesson: The Server-Client Model