Shilajit Dutta
Shilajit Dutta

Reputation: 11

How to make API calls server side REACT?

I am trying to render my react app server side for better SEO and better performance but since most of the content of the site is from an API and the API call is still happening on the client side the server is returning an almost black HTML template is there a way to make the API calls in server

P.S. I'm not using Redux

Upvotes: 0

Views: 403

Answers (1)

rouzbehsbz
rouzbehsbz

Reputation: 111

It is exactly what React as client and Express as server must do. When you choose to develop your frontend by React and use 'npm build' to get output from your whole React project. you get only "ONE" index.html file. so you can't render multiple html pages by Express. you can only render the main html file and use api's to render other routes. That's why you can't do such a thing.

Upvotes: 1

Related Questions