skip to Main Content

I’m currently working on a new ReactJS application. In all the previous applications I’ve built I used Express for the server side rendering. I used Express because routing in production mode wouldn’t work if I didn’t.

So I’ve recently discovered that it’s posible to just always redirect my React app to my index.html file and let the React routing just do it’s work. This also works when I deploy my application to production.

I know Express can be usefull for SEO porposes but other than that I have no idea why I would need to use it. So am I just missing something? Or is it just fine to don’t use Express with my React application if I don’t need any SEO.

3

Answers


  1. when deploying react application it is just usually an html and a JS file. So you need some kind of server to host it. Luckily there are services out there that offers that like S3, Github etc.
    You’re using Express because it can host the html and js files. So technically you don’t need specifically express but you need some server that will host your files.

    Login or Signup to reply.
  2. React configured as a Single Page App, renders the express routing all but unnecessary. The standard transition from a web server rendered app to a single page app is to change the server into a REST Web API and any server side data needed from the React App is obtained through AJAX calls.

    So in most cases you don’t need Express when you are using React to handle your routing except for in less common cases when you might want to use express as a reverse proxy or something.

    Login or Signup to reply.
  3. If you want to do server-side rendering, you’ll need a node server (typically but doesn’t have to be express) to render your React components. This could not only help with SEO but also allow your page to appear to load faster (you wouldn’t have to wait for the JS to download and run before the user sees the HTML).

    If you don’t care about the benefits, don’t use SSR.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search