Dashboard as First Page
How to set Dashboards First page instead landing
This section explains how to set the Dashboard page as the default starting page, skipping the landing page, for cases where it is not needed.
Update route at:- src/routes/index.tsx
src/routes/index.tsx
// import { lazy } from 'react';
import { createBrowserRouter } from 'react-router-dom';
// project import
import MainRoutes from './MainRoutes';
// import LoginRoutes from './LoginRoutes';
import ComponentsRoutes from './ComponentsRoutes';
// import { SimpleLayoutType } from 'config';
// import SimpleLayout from 'layout/Simple';
// import Loadable from 'components/Loadable';
// render - landing page
// const PagesLanding = Loadable(lazy(() => import('pages/landing')));
// ==============================|| ROUTING RENDER ||============================== //
const router = createBrowserRouter(
[
// {
// path: '/',
// element: <SimpleLayout layout={SimpleLayoutType.LANDING} />,
// children: [
// {
// index: true,
// element: <PagesLanding />
// }
// ]
// },
// LoginRoutes,
MainRoutes,
ComponentsRoutes
],
{ basename: import.meta.env.VITE_APP_BASE_NAME }
);
export default router;
src/routes/index.jsx
// import { lazy } from 'react';
import { createBrowserRouter } from 'react-router-dom';
// project import
import MainRoutes from './MainRoutes';
// import LoginRoutes from './LoginRoutes';
import ComponentsRoutes from './ComponentsRoutes';
// import { SimpleLayoutType } from 'config';
// import SimpleLayout from 'layout/Simple';
// import Loadable from 'components/Loadable';
// render - landing page
// const PagesLanding = Loadable(lazy(() => import('pages/landing')));
// ==============================|| ROUTING RENDER ||============================== //
const router = createBrowserRouter(
[
// {
// path: '/',
// element: <SimpleLayout layout={SimpleLayoutType.LANDING} />,
// children: [
// {
// index: true,
// element: <PagesLanding />
// }
// ]
// },
// LoginRoutes,
MainRoutes,
ComponentsRoutes
],
{ basename: import.meta.env.VITE_APP_BASE_NAME }
);
export default router;
Add default dashboard route: src\routes\MainRoutes.tsx
src\routes\MainRoutes.tsx
....
const MainRoutes = {
path: '/',
children: [
{
path: '/',
element: <DashboardLayout />,
children: [
{
path: '/',
element: <DashboardDefault />
},
{
path: 'dashboard',
children: [
{
path: 'default',
element: <DashboardDefault />
},
....
]
}
...
]
};
src\routes\MainRoutes.jsx
....
const MainRoutes = {
path: '/',
children: [
{
path: '/',
element: <DashboardLayout />,
children: [
{
path: '/',
element: <DashboardDefault />
},
{
path: 'dashboard',
children: [
{
path: 'default',
element: <DashboardDefault />
},
....
]
}
...
]
};
Comment out the
AuthGuard
wrapper for the routes within theDashboardLayout
element:
src/layout/Dashboard/index.tsx
// import AuthGuard from 'utils/route-guard/AuthGuard';
...
...
return (
// <AuthGuard>
<Box sx={{ display: 'flex', width: '100%' }}>
<Header />
...
</Box>
// </AuthGuard>
)
src/layout/Dashboard/index.jsx
// import AuthGuard from 'utils/route-guard/AuthGuard';
...
...
return (
// <AuthGuard>
<Box sx={{ display: 'flex', width: '100%' }}>
<Header />
...
</Box>
// </AuthGuard>
)
Last updated