Koa Next Middleware
npm install koa-next-middleware
or
yarn add koa-next-middleware
const Koa = require('koa');
const Next = require('Next');
const LRUCache = require('lru-cache);
const NextMiddleware = require('koa-next-middleware');
const app = new Koa();
const isDev = process.env.NODE_ENV !== 'production';
const ssrCache = new LRUCache({
max: 100,
maxAge: 1000 * 60 * 60 // 1hour
});
const appnext = Next({
dev: isDev
});
app.use(NextMiddleware(appnext, {
cache: isDev ? null : ssrCache
}));
app.listen(3000);
MIT@PLDaily