Getting started with hapijs – Hello world

Create a server.js file with the following contents:

'use strict';

const Hapi = require('hapi');

// Create a server instance
const server = new Hapi.Server();

// Specify connections (server available on http://localhost:8000)
    port: 8000 

// Add a route
    method: 'GET',
    handler: function (request, reply) {
        return reply('hello world');

// Start the server
server.start((err) => {
    if (err) {
        throw err;

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

Start Hapi.js Server

Run node server.js and open http://localhost:8000/hello in your browser.

if you want to reproduce, please indicate the source:
Getting started with hapijs – Hello world - CodeDay