Hacker News new | ask | show | jobs
by oscarteg 2252 days ago
Using React is really bad for your SEO. If you want to use React, use something like Nextjs or Gatsby to compile it into a static HTML website.
5 comments

If you want to use React, use something like Nextjs or Gatsby to compile it into a static HTML website.

Gatsby doesn't compile to a static HTML website. It compiles to a static site. There's a subtle difference. The pages are rendered on the server and served as static assets, but the entire React routing and content loading is still there. When a visitor loads a page it renders and then gets turned from plain HTML back in to a React again. When you navigate from one page to the next all the content for further pages is preloaded. You are not loading a full HTML page for each link you click on (which is exactly what makes it feel so lovely and fast - everything is being preloaded behind the scenes).

I've built API powered React sites with almost no consideration for SEO that Google has indexed without issue. My experience has been that as long as the API requests for content are quick Google is happy to wait and index correctly as expected. YMMV obviously.
Almost like people have forgotten that this exists[1] in React. Also, your logic is true to any SPA, not just React.

And Google has started to index SPAs[2] as well even though it's not instant like others have mentioned.

[1] https://reactjs.org/docs/react-dom-server.html#rendertostati...

[2] https://youtu.be/PFwUbgvpdaQ?t=836

Citation needed.

Google bot runs JavaScript these days. I'm sure proper SEO is possible in the worlds most popular UI framework.

Single-page apps (SPAs) using client-side rendering (CSR) like React do get indexed by Google, it's just not instant. Depending on how long it takes for the content to load, the Googlebot might not be able to figure out the correct on-page SEO.

If SEO is a critical requirement, I'd recommend either server-side rendering (SSR) through a framework like Next.js or completely static sites through whatever framework you prefer (Next.js, Gatsby, 11ty, Hugo, Jekyll, etc, etc).

I suspect folks using a free react landing page template aren't super concerned about SEO.