I am building a ReactJS application with MobX, and I am trying to make it universal app (server-rendering), but I have some issues and questions. First of all, I don't know how to handle user authentication on server-side rendering. I was saving before the token of the user in the browser's localStorage, but with server-rendring, it seems that I cannot access the localSotrage through the window. So fo example if I have some paths that user could go only if he signed in, now I cannot handle this because the window is undefined. Any suggestions?
I solved this issue with Cookies. Just use any cookies package, like universal-cookies. Since the cookies can be accessed both from the client and the server, so this is the best place to store the currentUser and token.