Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Shows how to use view templating with hapi within node.
'use strict';
const Hapi = require('hapi');
const server = new Hapi.Server();
server.connection({ port: 8000 });
// test by using this on browser:
// http://localhost:8000/kevin
server.register(require('vision'), () => {
engines: {
hbs: require('handlebars')
relativeTo: __dirname,
layout: true,
path: 'views'
method: 'GET',
path: '/{name?}',
handler: function(request, response) {
response.view('home', { name: || 'World' });
server.start(() => console.log(`Started at ${}`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment