Relay: can we do server side rendering using React Suspend, Relay useLazyLoadQuery, nextjs?

Created on 26 Dec 2019  Â·  6Comments  Â·  Source: facebook/relay

React Suspend is not yet available for server side, but it seems the react-ssr-prepass is a temporary solution, is there a tempory solution to do server siderrendering using the three tools currently?

wontfix

Most helpful comment

add react@experimental and react-dom@experimental and put reactMode as concurrent on your next.config.js:

module.exports = {
  experimental: {
    reactMode: 'concurrent'
  }
}

see: https://github.com/vercel/next.js/discussions/10645

All 6 comments

you should try, and let us know

I tried this for my own, didn’t succeed

I've wrote a blog post how I make Relay work well with SSR

https://dev.to/sibelius/adding-server-side-rendering-to-a-relay-production-app-30oc
https://medium.com/@sibelius/adding-server-side-rendering-to-a-relay-production-app-8df64495aebf

I think you can use fetchQuery instead of prepare (preloadQuery) on server side rendering with store-and-network fetchPolicy to solve your first render

add react@experimental and react-dom@experimental and put reactMode as concurrent on your next.config.js:

module.exports = {
  experimental: {
    reactMode: 'concurrent'
  }
}

see: https://github.com/vercel/next.js/discussions/10645

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MartinDawson picture MartinDawson  Â·  3Comments

amccloud picture amccloud  Â·  3Comments

bondanherumurti picture bondanherumurti  Â·  3Comments

piotrblasiak picture piotrblasiak  Â·  3Comments

sgwilym picture sgwilym  Â·  4Comments