Managing user's global state on next.js application

Pavle  picture Pavle · Jul 12, 2019 · Viewed 12.3k times · Source

I am coming from the world of SPA's and REST/GraphQl API's. Now I am building personal project with Next.js library for SSR(Server Side Rendered) React App.

Since I used Redux in all of my single page Apps, I'm now wondering how should I manage user state when every route user visits, a new link is loaded and the page has been refreshed.

I found some info about sessions and cookies, but neither of those are familiar to me. I looked at some online articles about using Redux with Next.js but it seems complicated.

Answer

felixmosh picture felixmosh · Oct 26, 2019

Let's simplify how Next works, browser sends a request to the server, Next renders on server side, returns an html, then, Next re-hydrate the page, and from now it behaves as SPA.

Next has an example folder basically for every technology including redux.

Checkout the redux example.