0.1.2 • Published 6 years ago
@davidbailey00/next-preact v0.1.2
Next.js + preact
Installation
npm install --save @zeit/next-preact preact preact-compat preact-contextor
yarn add @zeit/next-preact preact preact-compat preact-contextUsage
Create a next.config.js in your project
// next.config.js
const withPreact = require('@zeit/next-preact')
module.exports = withPreact({
  /* config options here */
})Then create a server.js
// server.js
require('@zeit/next-preact/alias')()
const { createServer } = require('http')
const next = require('next')
const app = next({ dev: process.env.NODE_ENV !== 'production' })
const port = process.env.PORT || 3000
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
  createServer(handle)
  .listen(port, () => {
    console.log(`> Ready on http://localhost:${port}`)
  })
})Optionally you can add your custom Next.js configuration as parameter
// next.config.js
const withPreact = require('@zeit/next-preact')
module.exports = withPreact({
  webpack(config, options) {
    return config
  }
})0.1.2
6 years ago