Template rendering support for hapi.js.

Latest Version: 7.0.3

npm: npm install @hapi/vision

yarn: yarn add @hapi/vision

Module Status:
Version License Node Dependencies CI
hapi helmet github logo
BSD 16, 18, 20 Dependency Status Build Status
hapi helmet github logo
BSD 16, 18, 20 Dependency Status Build Status


vision decorates the server,
request, and
h response toolkit interfaces with additional
methods for managing view engines that can be used to render templated responses.

vision also provides a built-in handler implementation for creating templated responses.

Most interaction with vision is done via the h response toolkit
and server interfaces.


const Hapi = require('@hapi/hapi');
const Vision = require('@hapi/vision');

const server = Hapi.Server({ port: 3000 });

const provision = async () => {

    await server.register(Vision);
    await server.start();

    console.log('Server running at:',;


The examples in the examples folder can be run with node.

git clone && cd vision
npm install

node examples/handlebars

☝️ That command will run the handlebars basic template. There are three more examples in there: for helpers, layout, and partials.

Use this hierarchy to know which commands to run, e.g.

node examples/mustache
node examples/mustache/partials
node examples/jsx
- cms // A bare-bones Content Management System with a WYSIWYG editor
- ejs
  - layout
- handlebars
  - helpers
  - layout
  - partials
- jsx // React server-side rendering with `hapi-react-views`
- marko
- mixed // Using multiple render engines (handlebars and pug)
- mustache
  - layout
  - partials
- nunjucks
- pug
- twig

vision is compatible with most major templating engines out of the box. Engines that don't follow the normal API pattern can still be used by mapping their API to the vision API. Some of the examples below use the compile and prepare methods which are part of the API.