req.locals, res.locals or even your own defined key res.userData can be used. However, when using a view engine with Express, you can set intermediate data on res.locals in your middleware, and that data will be available in your view (see this post). It is common practice to set intermediate data inside of middleware on req.locals to avoid overwriting view data in res.locals, though this is not officially documented.
//example:
//set res.locals.company in to middleware
// just use "company" for accessing the "res.locals.company" value.
app.use(function(req, res, next){
res.locals.items = "Value";
next();
});
//your routes follow
app.use(‘/’, home);
// this is for render
res.render('layout', {title: 'My awesome title',view: 'home', item :res.locals.items });