0.0.3 • Published 6 years ago

next-inferno-typescript v0.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Next.js + Inferno + TypeScript

Use Inferno :fire: with Next.js and TypeScript to get even faster :zap: rendering.

Installation

npm install --save next-inferno-typescript inferno inferno-compat inferno-clone-vnode inferno-create-class inferno-create-element

or

yarn add next-inferno-typescript inferno inferno-compat inferno-clone-vnode inferno-create-class inferno-create-element

Usage

@TODO

Create a next.config.js in your project

// next.config.js
const withInferno = require('next-inferno')
module.exports = withInferno()

Then create a server.js

// server.js
require('next-inferno/alias')()
const { createServer } = require('http')
const next = require('next')

const app = next({ dev: process.env.NODE_ENV !== 'production' })
const handle = app.getRequestHandler()
const port = process.env.PORT || 3000

app.prepare()
.then(() => {
  createServer(handle)
  .listen(port, () => {
    console.log(`> Ready on http://localhost:${port}`)
  })
})

Then add or change "scripts" section of your package.json:

...
"scripts": {
  "dev": "node server.js",
  "build": "next build",
  "start": "NODE_ENV=production node server.js"
},
...

Optionally you can add your custom Next.js configuration as parameter

// next.config.js
const withInferno = require('next-inferno')
module.exports = withInferno({
  webpack(config, options) {
    return config
  }
})