How to use HTML as the view engine in Express with JavaScript?

Spread the love

Sometimes, we want to use HTML as the view engine in Express with JavaScript.

In this article, we’ll look at how to use HTML as the view engine in Express with JavaScript.

How to use HTML as the view engine in Express with JavaScript?

To use HTML as the view engine in Express with JavaScript, we use the express.static middleware.

For instance, we write

app.use(express.static(__dirname + "/public"));

to expose the /public folder as the static folder directory.

Then we can open any file in the folder directly in the browser.

Conclusion

To use HTML as the view engine in Express with JavaScript, we use the express.static middleware.

Leave a Reply

Your email address will not be published. Required fields are marked *