SPA vs MPA || React-Router vs ExpressJs

1.2k views Asked by At

Could you please explain me why would I use React-Router vs when ExpressJs. I somewhat understand React-Router does client side rendering which is good for SPA, whereas Express is for MPA. However I can't get the grasp as of WHEN should I be using which, I would be greatly appreciated if you could give an insight on this. Thanks.

1

There are 1 answers

0
Elliot Blackburn On BEST ANSWER

ExpressJS is a nodejs library for building web servers. Express has routing capabilities but this is for server side HTTP calls, where as react-router is for frontend application routing.

React-router will tell you which part of your application to display, components within that application may make HTTP calls to your server, ExpressJS will receive these requests and route them off to the particular middleware / controllers that should handle that request.

They are two very separate things, one is client side and one is server side, you will find that you'll need both for your application. React-Router indicates what to display on the frontend, where as ExpressJS's router will direct HTTP calls to the appropriate request handler.

ExpressJS is simply a HTTP server package built for nodejs and is not restricted to the type of application wish to build. You can use templating and build a multi-page application, or you can just build HTTP API endpoints and use those to service a single page application.

I'd recommend taking a few tutorials around nodejs and Express, this will help you build a foundation of knowledge around the split between server-side and client-side services.