Codementor Events

Server Side Routing vs Client-Side Routing

Published Sep 09, 2019
Server Side Routing vs Client-Side Routing

There are several differences between server-side routing and client-side routing and we are going to know all about them but first, we need to understand how the both of them work in there own unique way.
In server-side routing what usually happens when you are entering a URL for the first time or you want to change the page, maybe you click on the about us section or the navbar, the browser immediately detects that change in the URL then the browser makes an HTTP request to the server then the server re-renders the HTML into the application, now this can be very expensive and would require time-based on the internet speed and some other factors.
In client side routing we don't need to go through all these stages, although when we first load the application that is inputing the web address the full react app is being rendered from the server, but after that when you want to change pages, maybe you click on the navbar the browser watches for change in the URL and immediately it detects change in the URL it uses the HTML5 history API to fetch the page that has already been loaded in when the application was first loaded in and returns it to the browser, and how react routerknows which particular page the user is making reference to is by going off to the set of configuration which would have a couple of URLs and components that would render to the root of those URLs, so when we click on the navbar react router goes on to search for the URL and its matching component and then that component is being rendered with a javascript function call.
So using react-router this would enable us to rerender our application with client-side javascript that is going to allow us to create a single page application that would enable us to swap out application simulating the page change.
The difference between this two routing have been stated above server sides needs to keep making requests to the server in order for the application to rerender, but client side does not need to keep make request to the server, it just does it once when the application is being loaded into the browser any other navigation or page change is just being rendered from the already saved application, so a client side application can still function without the internet as long as it has already being loaded in with the internet.

Discover and read more posts from Nwoga kingsley
get started
post commentsBe the first to share your opinion
Show more replies