πŸ›£οΈRouting

Page and URL routing

Able Pro routing system is based on react-router and its package react-router-dom, it also uses code splitting for better performance.

How can I add a new page with a menu item?

You can use the explanation below to add/remove menu routes and their menu items.

Configure route

Open src\routes\index You will find the example code below. In the code below, we have shown four different routes. <MainRoutes/> This is the main layout routing you see after login.

src/routes/index.tsx
import { lazy } from 'react';
import { createBrowserRouter } from 'react-router-dom';

// project-imports
import ComponentsRoutes from './ComponentsRoutes';
import LoginRoutes from './LoginRoutes';
import MainRoutes from './MainRoutes';

import Loadable from 'components/Loadable';
import { SimpleLayoutType } from 'config';
import SimpleLayout from 'layout/Simple';

// render - landing page
const PagesLanding = Loadable(lazy(() => import('pages/landing')));

// ==============================|| ROUTES RENDER ||============================== //

const router = createBrowserRouter(
  [
    {
      path: '/',
      element: <SimpleLayout layout={SimpleLayoutType.LANDING} />,
      children: [
        {
          index: true,
          element: <PagesLanding />
        }
      ]
    },
    LoginRoutes,
    ComponentsRoutes,
    MainRoutes
  ],
  { basename: import.meta.env.VITE_APP_BASE_NAME }
);

export default router;

Add a New menu/route in the main layout

To add one more menu item in <MainRoutes />, update the following file at the same location src\routes\MainRoutes.js

Last updated