I found that OP is right that cookie storage is the best option. If you use reaction, abbreviation and expression for a universal application, then the option that worked for me was https://github.com/eXon/react-cookie .
Essentially:
In the server code you can use:
import cookie from 'react-cookie'; function handleRender(req, res) { cookie.setRawCookie(req.headers.cookie); // Create new Redux store instance const store = createStore(rootReducer, { username: cookie.load('username') || '', accessLevel: cookie.load('accessLevel') || userRoles.public, }); //other react/redux/express related code }
In your reaction applications inside the components, you can simply save cookies directly:
import cookie from 'react-cookie'; //first parameter is anything you want, second is the data you want to save cookie.save( 'username', username ); cookie.save('accessLevel', accessLevel);
Further, if you want to save the object, like me, you can go to JSON.stringify(your object) . cookie.load will automatically analyze it for you.
In my code, I called cookie.save from actions, but you can call it directly in components or any abstraction that you have.
source share