How to Render HTML File in Node JS Express

How to Render HTML File in Node JS Express

In this article, we will explain to you how to render HTML file in node js Express. sometimes we need to render the HTML file in node js.

We will create a node js application with express. An express is a nodejs npm package that helps to render the HTML page into the nodejs application.

Node Js Application Setup

First, we will open the command prompt and create the application in our directory. for this, you can follow the below command.

Install NPM Package

After the done setup node js application, we will install the express npm package. so you can see the following npm command.

Render HTML web pages

In this step, We will render HTML web pages using sendFile function. so you can see our server.js file example.
server.js

Create a new index.html file and open it paste below code.
index.html

Run Node js Application

we will run the node js application using the below command. so you can follow the below command.

Now you can run the example using the below Url in the browser.

Please follow and like us: