Reputation: 91
React uses Node server to handle server side rendering. So, when crawler requests a URL, Django server requests Node server which calls React.renderToString and generates HTML. The HTML is sent to Django which sends it to the crawler. Isn't there a performance issue in this as I'm calling Node and requesting for data and then sending it to the crawler? Won't there be a performance penalty compared to rendering it directly in Django and sending? SEO is critical in my application, but I also want to use client side rendering. What should be the best trade-off?
Upvotes: 2
Views: 1170
Reputation: 2402
I'm not sure what the performance penalty would be and whether or not it would be worth building a public facing site as an SPA. I would keep that for admin and areas where users have to log in, not in public pages where I want Google and other crawlers to index the pages. Even if you did use React and Node to generate that page, the subsequent pages after would be all ajax and the html that was generated would never change, I find that to be useless IMO.
To summarize, keep your public site in Django and the admin site React, that would yield the best results and get you that SEO pages you want.
EDIT 2022 My answer was from many years ago and needs an update. If you're going the React route you should consider NextJS or Remix; both handle the SSR (server side rendering) to generate the HTML so that crawlers could index your content and so you can cover your SEO needs.
Upvotes: 1