Switch branches/tags
Nothing to show
Find file History
timneutkens Publish
 - @zeit/next-bundle-analyzer@0.1.3-canary.1
 - @zeit/next-css@1.0.2-canary.2
 - @zeit/next-less@1.0.2-canary.2
 - @zeit/next-mdx@1.2.1-canary.0
 - @zeit/next-preact@0.1.1-canary.0
 - @zeit/next-sass@1.0.2-canary.2
 - @zeit/next-source-maps@0.0.4-canary.1
 - @zeit/next-stylus@1.0.2-canary.2
 - @zeit/next-typescript@1.1.2-canary.0
 - @zeit/next-workers@1.0.1-canary.1
Latest commit 404368d Nov 15, 2018
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
alias.js Add xo Jan 28, 2018
index.js Add preact aliases for literal react and react-dom Fixes #119 Mar 29, 2018
package.json Publish Nov 14, 2018
readme.md Add missing port (#118) Mar 27, 2018

readme.md

Next.js + preact

Use preact with Next.js

Installation

npm install --save @zeit/next-preact preact preact-compat

or

yarn add @zeit/next-preact preact preact-compat

Usage

Create a next.config.js in your project

// next.config.js
const withPreact = require('@zeit/next-preact')
module.exports = withPreact()

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
  }
})