facebook / relay

Relay is a JavaScript framework for building data-driven React applications.
https://relay.dev
MIT License
18.39k stars 1.82k forks source link

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

Open videni opened 4 years ago

videni commented 4 years ago

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?

sibelius commented 4 years ago

you should try, and let us know

renanmav commented 4 years ago

I tried this for my own, didn’t succeed

sibelius commented 4 years ago

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

morrys commented 4 years ago

I created this example project in relay-hooks: https://github.com/relay-tools/relay-hooks/tree/master/examples/suspense/nextjs-ssr

AugustoCalaca commented 4 years ago

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

stale[bot] commented 3 years ago

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.