Hook cookies get/set on Express for server-rendering
State management integration
-
universal-cookie
- Universal cookies for JavaScript -
react-cookie
- Universal cookies for React
npm install universal-cookie-express --save
cookiesMiddleware()
express middleware set req.universalCookies
const express = require('express');
const cookiesMiddleware = require('universal-cookie-express');
const app = express();
app.use(cookiesMiddleware()).use(function (req, res) {
// get the user cookies using universal-cookie
req.universalCookies.get('myCat');
});