-
Notifications
You must be signed in to change notification settings - Fork 36
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
SSR not working properly #335
Comments
Here I provide a repro. repo: https://github.com/juanstiza/apollo-client-nextjs-repro. |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
Hi @juanstiza 👋 Your question brings up an interesting fact about React streaming SSR: it requires JavaScript on the client in order to work. With progressive hydration, after the initial HTML of your application is rendered and sent to the browser, React generates the HTML for suspending components as they receive data and sends it to the same stream along with a script tag so it can be rendered in place of the fallback that was in the initial HTML payload. If you remove Apollo Client from your example and replace it with a different data fetching hook that does some asynchronous work you should see the same thing. I'll leave this issue open for now, let me know if you have any other questions :) |
@alessbell Indeed, we used to do it like this but using Apollo, without the new hooks and streaming. I guess we'll keep it like that until another solution arises. Thanks for the insight! |
One thing to add maybe: if Next.js detects a search engine crawler, they will not show suspense fallbacks and start out-of-order-streaming, but instead wait until all data has been fetched and then flush the whole page in order, so it will not require JavaScript from the perspective of a web crawler. The behaviour you are seeing here is reserved for real users with real browsers. |
@phryneas This is interesting! is there a way of tricking Next.js to render the page as if I were a crawler? I'm googling it as I finish typing this :) |
You'd set a user-agent accordingly. |
Hi all!
I'm having a strange issue while setting up SSR. I haven't found this problem being described anywhere else. Any help will be appreciated!
What I expect:
Loading the page in the browser without javascript should render the correct content.
What I get:
The page renders only the fallback. If I load the page again without restarting the server, I can see the content.
Dependencies
react
: ^18, installed: 18.2.0@apollo/client
: ^3.10.8, installed: 3.10.8@apollo/experimental-nextjs-app-support
: ^0.11.2, installed: 0.11.2graphql
: ^16.9.0, installed: 16.9.0Setup
Apollo provider
Page component
Content component
Product component, it should render the product's title.
The text was updated successfully, but these errors were encountered: