Framework400K+/wkBSD-3-Clause

@hapi/hapi

Hapi (originally Happy.js) is a rich framework for building applications and services on Node.js, created by Eran Hammer at Walmart Labs. Unlike Express's minim

Installation

npm
npm install @hapi/hapi
yarn
yarn add @hapi/hapi
pnpm
pnpm add @hapi/hapi

Import

ESM
import Hapi from '@hapi/hapi';

Quick Example

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

server.route({
  method: 'GET',
  path: '/',
  handler: () => 'Hello World',
});

await server.start();

About @hapi/hapi

Hapi (originally Happy.js) is a rich framework for building applications and services on Node.js, created by Eran Hammer at Walmart Labs. Unlike Express's minimalist approach, Hapi provides a comprehensive built-in feature set including input validation using Joi schemas, authentication with multiple strategies, caching with catbox, cookie management, and detailed request lifecycle hooks. Hapi's configuration-centric philosophy means most features are enabled through declarative route configuration rather than imperative middleware chains. The framework excels in enterprise environments where strict input validation, detailed logging, and robust error handling are essential. Hapi's plugin system allows teams to organize applications into isolated, composable modules with their own routes, handlers, and dependencies. The framework handles request validation, payload parsing, and authentication declaratively at the route level, reducing boilerplate and potential security oversights. Hapi's ecosystem includes official packages for templating (vision), static files (inert), and API documentation (lout), providing a batteries-included experience for teams that prefer convention over configuration.

Quick Facts

Package@hapi/hapi
CategoryFramework
Weekly Downloads400K+
LicenseBSD-3-Clause
Installnpm install @hapi/hapi

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.