Routing

Doot React is having a routing setup based on React-Router.

You can find our template's router configuration in the src/routes folder. the src/routes/allRoutes.js file is containing all routes of our template.

We have also added Authmiddleware in the src/routes/AuthProtected.js file, to handle redirection for non-auth users. you can also handle roles-based routing, redirections, set accessToken here as per your need.

Note: All private & public routes are rendered in the src/App.js file.

How to add a new route?

You can easily add, change or remove any route by simply making the changes described below:

1. Open src/routes/allRoutes.tsx file, declare your component. E.g.

import newPage from "../pages/newPage"

2. And make sure to add the entry for same with path and other properties like path and component same as other routes declared there. if your page is a public page (with the blank layout), then add the route in publicRoutes, and if your page is a private page (with the full layout) then add a route in privateRoutes. E.g.

{ path: "/new-page", component: <newPage /> }  

Each of these properties is explained below:

  • path : Url relative path
  • component : Actual component name which would get rendered when a user visits the path
Note : you don't need to restart the development server in order to see the menu changes getting in effect.
© Themesbrand.
Crafted with by Themesbrand