What is Single Page Application Routing ?

 Single Page Application Routing?

Earlier , we used to serve different web pages for the URL whenever the user redirects to the different path and whole application reloads where the sending http request to backend makes the application slower . So , in react there is a package name React Router which makes the multi page application feel to the single page application and the navigation concept in react seems feasible .

Single Page Application (SPA) where the whole application load at once and whenever user visits some path, it will fetch the data from the server for the particular component and make that page visible to the user which feels like multi page routing.

React Router package manager installed by npm  , and very important concept in react for the navigation  without the react router we cannot perform navigation in the single page application .

There are three steps to implement the react router and navigate through the different components after installing react router into your react app.

Step -1 

First step is to import the createBrowerRouter to the app ,  used to define the route definitions where we specify for which path , which component should be called .
Attributes of path and element is the basic properties for the array of routing object definitions . 

 

Step - 2

Now the second step is to create the component which will be called for the specified path . In our example we are rendering home page for the "/" route.


Step - 3

The last step , where you will rendered the page with the react routing by importing Router Provider . This component will be called and has a special attribute name router , will take the routing definitions  , so that it can render the routing for the react web.


These are the three steps , where you can render the page with the react -router . There are so many concepts of react- router which we will discuss later in the blog . Stay connected with the daily blog post !

Thank you for reading the blog post :)

Comments

Popular posts from this blog

Learn React Router v6 ( Part - 2)

Why use Typescript ?