fastify .get('/', function (request, reply) { // display from view request.req.locals.title = "Hello Wordl"; })
fastify.addHook('onRequest', (req, res, next) => { req.locals = {} next() }) fastify.use('/', (req, res, next) => { req.locals.a = 1 next() }) fastify .get('/', function (request, reply) { reply .send(request.req.locals) })