Accessing Express.js req or session from static html page

How to access Express.js req or session from static html page, for example, how to show the log-in username on the top of the index.html page

You need template engine.

For example:

If you use swig:

index.html:

<span>{{name}}</span>

index.js:

res.render("index.html",{
    name:req.session.userName
});

Express support many template engines,you can choose one as you like.