Design First Application Using Express
Last Updated :
05 Apr, 2025
In NodeJS, the task of designing a server was very difficult, but after the introduction of ExpressJS, which is a lightweight web application framework for NodeJS used to build the back-end of web applications relatively fast and easily.
Prerequisites
To get started with an ExpressJS application, NodeJS and NPM must be installed in your system.
Follow the article to inslaa Node and NPM in your system – How to Install NodeJS
Steps to design an ExpressJS application
Step 1: Create a project directory
First, you need to create a project folder in which you want to keep your project
mkdir my-express-app
cd my-express-app
Step 2: Initialize the Node project
After that, you need to initialize the project to install different dependencies and to fully use NodeJS
npm init -y
Step 3: Install ExpressJS
Now it’s time to install and add ExpressJS to your project using the following command.
npm install express
Dependencies
"dependencies": {
"express": "^4.21.2"
}
Step 4: Create the server File
Create a file named server.js in your project directory and set up your basic Express server inside server.js
JavaScript
const express = require('express');
const app = express();
const PORT = 3000;
app.get('/', (req, res) => {
res.send('Hello, Express!');
});
app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});
- Importing Express: const express = require(‘express’); imports the Express library, which is used to build web servers.
- Creating an Express App: const app = express(); creates an instance of an Express application.
- Handling Routes: app.get(‘/’, (req, res) => { res.send(‘Hello, Express!’); }); sets up a route to handle requests to the root URL (‘/’), sending a “Hello, Express!” message in response.
- Starting the Server: app.listen(PORT, () => { console.log(Server is running on http://localhost:${PORT}`); });` starts the server on port 3000 and logs a message to confirm it’s running.
Step 5: Run the Application
Start your server by running the following command in your current project directory that you are working upon
node app.js
Step 6: Visit the localhost
Visit http://localhost:3000 in your browser. You should see the message “Hello, Express!”.

Visit the localhost
Hooray! your first express application created successfully
Step 7: Add More Routes
Now, let’s add more routes to handle different types of HTTP requests, like GET and POST.
JavaScript
app.get('/about', (req, res) => {
res.send('About Page');
});
app.post('/submit', (req, res) => {
res.send('Form Submitted');
});
- Handling a GET Request: app.get(‘/about’, (req, res) => { res.send(‘About Page’); }); listens for GET requests to the /about route and responds with “About Page.”
- Handling a POST Request: app.post(‘/submit’, (req, res) => { res.send(‘Form Submitted’); }); listens for POST requests to the /submit route and sends “Form Submitted” as a response when the form is submitted.

/about route

post request at /submit rote
How the ExpressJS application works?
An ExpressJS application works by handling incoming HTTP requests, processing them, and sending back responses.
- The application listens for incoming requests (like GET, POST, PUT, DELETE) on specified routes (URLs).
- When a request comes in, it passes through middleware functions that can modify the request or perform actions (e.g., authentication, logging).
- The request is matched to the appropriate route (based on the URL and HTTP method), and a response is generated.
- The server sends back a response (e.g., HTML, JSON, or status message) to the client.
Why to use ExpressJS above other technologies?
- Minimal and Flexible: Express is lightweight and gives you the freedom to structure your app the way you want, without unnecessary overhead.
- Easy to Learn: It has a simple API and integrates well with other libraries, making it ideal for beginners and experienced developers alike.
- Fast Development: Built on Node.js, it offers fast handling of HTTP requests, helping you quickly build scalable web apps and APIs.
- Rich Ecosystem: Express has a huge community and a wide range of middleware to extend its functionality, making it easier to implement features like authentication or logging.
- Asynchronous and Non-blocking: Thanks to Node.js, Express handles multiple requests at once without blocking, making it perfect for I/O-heavy applications.
Use cases of ExpressJS application
- Building RESTful APIs: Express is commonly used to create APIs that allow clients to interact with the server via standard HTTP methods like GET, POST, PUT, and DELETE.
- Serving Static Files: Express can serve static files like images, CSS, and JavaScript, making it ideal for building websites or applications with front-end assets.
- Handling User Authentication: Express can manage user authentication (login/logout) using sessions, cookies, and third-party services like OAuth, making it a core part of user management systems.
- Real-time Applications: With libraries like Socket.io, Express can handle real-time communication, such as in chat applications or live notifications.
- Middleware Integration: Express allows the use of middleware to handle tasks such as logging, request validation, and error handling, making it useful for adding custom functionalities and improving app security.
Conclusion
ExpressJS simplifies back-end development by providing a fast and flexible framework for handling HTTP requests. It’s perfect for creating RESTful APIs, serving static files, handling user authentication, and much more. By using Express, you can quickly develop web applications with a clear and easy-to-understand structure, while maintaining high performance and scalability.
Similar Reads
Hospital Management Application using MERN Stack
In the fast-paced world of healthcare, it's vital to manage hospital tasks effectively to ensure top-notch patient care. This article explores creating a strong Hospital Management App using the MERN stack â that's MongoDB, Express, React, and Node.js, breaking down the process for easier understand
15+ min read
How to config properties in Express application ?
In this article, we will discuss how to config properties in Express Applications. There are two methods for configuring the properties in Express JS. Approach 1: Using Environment Variables (process.env) Environment variables in Express are an excellent method to simply and securely define items li
2 min read
Deploy Serverless Express Application to Vercel
Vercel is a serverless cloud-based hosting solution to host front-end and serverless applications. Express is a Node.JS framework and deploying serverless express application aids cost-cutting to nearly zero. Although the traditional way of deploying to the server is expensive and there is a limit o
3 min read
Steps to Create an Express.js Application
Creating an Express.js application involves several steps that guide you through setting up a basic server to handle complex routes and middleware. Express.js is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. Hereâs a
10 min read
Todo List Application using MEAN Stack
The todo list is very important tool to manage our tasks in this hectic schedule. This article explores how to build to-do list application using the MEAN stackâMongoDB, Express.js, Angular, and Node.js. Weâll walk you through the process of setting up backends with Node.js and Express.js, integrati
10 min read
Hospital Appointment System using Express
Hospital Appointment System project using Express and MongoDB contains various endpoints that will help to manage hospital appointments. In this project, there is an appointment endpoint for user management and appointment management. API will be able to register users, authenticate users, book appo
12 min read
Node First Application
NodeJS is widely used for building scalable and high-performance applications, particularly for server-side development. It is commonly employed for web servers, APIs, real-time applications, and microservices. Perfect for handling concurrent requests due to its non-blocking I/O model.Used in buildi
4 min read
REST API CRUD Operations Using ExpressJS
In modern web development, REST APIs enable seamless communication between different applications. Whether itâs a web app fetching user data or a mobile app updating profile information, REST APIs provide these interactions using standard HTTP methods. What is a REST API?A REST API (Representational
7 min read
Freelancer Portfolio Builder Application using MERN Stack
In today's digital age, having a professional portfolio is essential for freelancers to showcase their skills and attract potential clients. In this article, we'll dive into the process of building a Freelancer Portfolio Builder using the MERN (MongoDB, Express.js, React.js, Node.js) stack. This pro
5 min read
How to Deploy an Express Application to Vercel ?
Vercel is a popular cloud platform that is known for its excellent support in building and deploying scalable Frontend infrastructure. In this article, we will look into how to deploy an Express.js web Application to Vercel. We will use the Serverless computing feature of Vercel to deploy our expres
2 min read