Hapi Plugin for Nuxt.js
Nuxt.js plugin for Hapi.js
IMPORTANT: This plugin is compatible with Hapi >= 17
Setup
- Add
@nuxtjs/hapi
dependency to your project
yarn add @nuxtjs/hapi
- Register it on your server:
const Hapi = require('@hapi/hapi')
const nuxtPlugin = require('@nuxtjs/hapi')
await server.register({
plugin: nuxtPlugin
options: {
}
}
Options
dev
- Default:
true
(false
when environment variable NODE_ENV
is production
)
Automatically starts a Builder
allow to hot reload on dev. Should be disabled for production.
rootDir
- Default: current working directory
nuxtConfig
Resolved relative to rootDir
edge
Use nuxt-edge
instead of nuxt
package if set to true
baseURL
baseURL for SSR route handler
route
- Default:
{ id: 'nuxt.render', auth: false }
Hapi route options for SSR handler
routeMethod
Hapi route method. (Can be set to GET
for more strict handling)
Access nuxt
and builder
instances
This plugin exposes nuxt and builder (for dev only) instances to hapi.
const server = new Hapi.Server()
await server.register(HapiNuxt)
const { nuxt, builder } = server.plugins.nuxt
Access Hapi's internals.
The hapi request object is available from nuxtServerInit
and the context
under res.hapi
. Likewise, the hapi response toolkit will be available in res.hapi
.
Development
- Clone this repository
- Install dependencies using
yarn install
or npm install
- Start development server using
npm run dev
License
MIT License
Copyright (c) Nuxt Community