DEV Community

Discussion on: Mobx Server Side Rendering with Next.js

Collapse
alejomartinez8 profile image
Alejandro Martinez

Thanks for the article! I have 2 questions? 1) When is best place to fetch the data to hydrate the components? On initializeStore or how can I access to store(in server) in getServerSideProps? 2) Is possible to persist the userStore for example to avoid auth fetch in each request, or is needed to refresh the store(in server)?

Collapse
ivandotv profile image
Ivan V. Author
  1. Depends what you want to do, if you have static rendering, than you need to hydrate the data on the server (when static page is built). You should not access the store in getServerSideProps rather you should just return data that will later be used do populate stores - passed to the root store provider by the page component.
  2. I'm not really sure what you mean.