How to Render HTML File in Node JS Express?

By Hardik Savani June 16, 2021 Category : Node JS

In this article we will cover on how to implement how to render html file in node js express. i explained simply step by step node js route to html page. you can understand a concept of node js redirect to html page. you will learn node js express render html.

In this example, i will give you very simple example of how to render html file in node js express project. we will use sendFile() to render html file, let's see bellow example.

Create Node Project:

you can run bellow command to create node app.

mkdir my-request-app

cd my-request-app

npm init

Install Express:

npm install express

Create Server.js File

let's create server.js file with get and post route.


var express = require('express');

var app = express();

app.get('/',function(req,res) {

res.sendFile(__dirname + '/index.html');


app.listen(3000, () => console.log(`App listening on port 3000`))

Create index.html File


<!DOCTYPE html>



<meta charset="utf-8">




<p>This is simple html file call by!</p>





This is simple html file call by!

i hope it can help you...

Tags :