-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
approach recommended by vercel #61
Comments
The disadvantage is similar to other libraries I’ve seen in that they all rely on getServerSideProps or something similar. From my experience building apps, it is very much an anti pattern when using Relay. One of the largest benefits of Relay is that you can render using partially cached data and then re-fetch in the background, all while not delaying the navigation like getServerSideProps does. I understand it’s recommended by Vercel over getInitialProps, however it’s a far worse user experience when we have Relay at our disposal. We could technically remove the need for the _document addition I think by using the inline |
Thanks for your fast feedback 👍 I tried to draw the flow you described: So if I understand you correctly both cases behave the same way for a warm cache. For an empty cache your approach might have an advantage depending on how fast the hydration is. Just a minor side note on
// creates an instance once and store it until component dies
const [example] = useState(() => new Example()); |
You're mixing SSR + hydration + relay cache in your comparison which doesn't make sense I think. It's either SSR + hydration or if it's a local navigation instead of the initial page load there won't be SSR nor hydration. I'll make a comparison best to my knowledge: Initial page load:Probably the same except that the next.js example is way more simple and uses next.js features to move the data instead of creating a scirpt tag to the document. Obviously the example works with static pages while Page navigation:Next.js way
|
@FINDarkside Accurate and excellent summary! Thanks! |
next js shows an approach which allows using relay with:
the
initEnvironment
uses the native nextjs way to transfer data without adding another script tag: https://github.com/vercel/next.js/blob/canary/examples/with-relay-modern/lib/relay.jsit seems to be easier for integration as it doesn't require a _document.tsx
do you see any disadvantage in their approach?
The text was updated successfully, but these errors were encountered: