Using Swig Templates with Hapi.js #nodejs #javascript @hapijs

Oscar Brito

While migrating a node.js application from Express to Hapi.js I found the need to use Swig as template engine instead of handlebars.

I prefer Swig because it have hierarchy blocks (aka extends) that work way better than the handlebars partials.

Simply, to make it work you just have to:


views: {
path: "./views/",
engines: {
html: "swig"


Be sure that you have included the the Swig dependency on package.json.

At last, be sure you check Hapi.js if you are thinking on a Server Framework for node.js ...


Visit for more informations, contacts and news about Web Development.
See other blog posts at

Divhide purpose is to follow the HTML5 movement and contribute with applications which prove the quality of technology.

Feel free to contact divhide.