Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Latest commit

 

History

History
60 lines (40 loc) · 1.61 KB

README.md

File metadata and controls

60 lines (40 loc) · 1.61 KB

nextjs-koa-middleware

NextJS koa middleware

CircleCI npm npm LICENSE Dependabot Status

System Requirements

Installation

# npm
npm i nextjs-koa-middleware
# yarn
yarn add nextjs-koa-middleware

Peer Dependency

Usage

  • Define environment variables:
NODE_ENV=development

# Relative path to .next directory
NEXT_CLIENT_DIR=/
NEXT_CONFIG_PATH=/next.config.js
  • Define NextJS Routes:
import Router from 'koa-router'
import { handle, render, defaultReturn } from 'nextjs-koa-middleware'

const nextRouter = new Router()

nextRouter.use(defaultReturn())
nextRouter.get('/custom-path', render('pageComponentName'))
nextRouter.all('*', handleRoutes())

export default nextRouter

License

Copylefted (c) 2020 Henrique Carvalho da Cruz Licensed under the MIT license.