You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is not the best way to make a fetch call inside a next component. The functions that trigger side effects should be rendered in client side and only inside useEffect.
In the above example, you can either use getServerSideProps to fetch the data in the server itself and then pass it to the given component as props or remove the side effect ( fetch call ) as a whole from the component.
Now coming to your question, yes the hidden property hinders SEO. You can follow the above suggestion to improve the SEO of this page.
Link to the code that reproduces this issue
https://github.com/trantrongbinh/next-demo/blob/main/src/app/page.tsx
To Reproduce
when i fetch in page.js:
and view page source then html wrapped in hidden div:
but if i without fetch:
then output html like:
Does wrapping in a hidden div affect SEO? If so, how can I fix it?
Current vs. Expected behavior
Does wrapping in a hidden div affect SEO? If so, how can I fix it?
Provide environment information
Which area(s) are affected? (Select all that apply)
Output
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
No response
The text was updated successfully, but these errors were encountered: