hapi-nextjs
v0.1.1
Published
A nextjs plugin for hapi Edit
Downloads
3
Readme
hapi-nextjs
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
onnext >= 2
, so bring your ownnext
- binds a catch-all route, so add your custom routes/plugins before registering
Options
- passes plugin
options
directly tonext
, in2.x
those options are:dev
(bool
) whether to launch Next.js in dev mode - defaultfalse
dir
(string
) where the Next project is located - default'.'
quiet
(bool
) Hide error messages containing server information - defaultfalse
Contribute
PRs welcome! Please read the contributing guidelines and the code of conduct.