How to send server-side data to view file in Express?

Hi folks, I’m wondering if it’s possible to send data from the server to the view (HTML) file in an Express app (such as Glitch’s hello-express)?

For example, in Koa, we can do this:

router.get('/', (ctx, next) => {
  return ctx.render('./index', { 
    user: 'eka' 

I’ve been looking around for examples of Express apps that do similar thing in server.js (not in client.js) but haven’t found any.

Any help would be appreciated, thanks!

Hey @ekafyi – I know it’s been a while, but I’d be happy to help with this if you’re still looking for an answer! I was just working on this issue myself last week.

You can use the ejs module to pass the user as <%= user %>