Hook cookies get/set on Koa for server-rendering
State management integration
universal-cookie
- Universal cookies for JavaScriptreact-cookie
- Universal cookies for React
npm install universal-cookie-koa --save
cookiesMiddleware()
koa middleware set req.universalCookies
const Koa = require('koa');
const cookiesMiddleware = require('universal-cookie-koa');
const app = new Koa();
app.use(cookiesMiddleware()).use(function (ctx) {
// get the user cookies using universal-cookie
ctx.request.universalCookies.get('myCat');
});