hapi-nextjs

0.1.1 • Public • Published

hapi-nextjs

npm standard

A nextjs plugin for hapi

This plugin provides an easy way to add a custom hapi server to a nextjs project.

NOTE: There are currently no tests for this plugin.

Table of Contents

Install

npm install hapi-nextjs

Usage

 
const Hapi = require('hapi')
const server = new Hapi.Server()
 
const dev = process.env.NODE_ENV !== 'production'
const port = parseInt(process.env.PORT || 3000, 10)
 
const nextPlugin = {
  register: require('hapi-nextjs')
  options: { dev }
}
 
server.connection({ port })
server.register(nextPlugin, (err) => {
  if (err) throw err
 
  server.start((err) => {
    if (err) throw err
 
    console.log(`> Ready on ${server.info.uri}`)
  })
})
 

Details

  • has a peerDependency on next >= 2, so bring your own next
  • binds a catch-all route, so add your custom routes/plugins before registering

Options

  • passes plugin options directly to next, in 2.x those options are:
    • dev (bool) whether to launch Next.js in dev mode - default false
    • dir (string) where the Next project is located - default '.'
    • quiet (bool) Hide error messages containing server information - default false

Contribute

PRs welcome! Please read the contributing guidelines and the code of conduct.

License

MIT © Jack Boberg.

Readme

Keywords

Package Sidebar

Install

npm i hapi-nextjs

Weekly Downloads

2

Version

0.1.1

License

MIT

Last publish

Collaborators

  • jackboberg