This guide walks you through adding a new route in your react-router-dom
setup.
// src/pages/AboutUs.jsx import React from "react"; const AboutUs = () => { return (
); }; export default AboutUs;About Us
Welcome to the About Us page.
allRoutes.jsx
// src/routes/allRoutes.jsx import AboutUs from "@src/pages/AboutUs"; const routes = [ { path: "/", component: <DashboardsPage /> }, { path: "/about-us", component: <AboutUs /> }, // ✅ Sidebar enabled ]; const nonAuthRoutes = [ { path: "/page/contact-us", component: <ContactUs /> }, { path: "/auth", component: <Auth /> }, // ✅ No sidebar ]; export { routes, nonAuthRoutes };
// src/routes/Routing.jsx import { Route, Routes } from "react-router-dom"; import { nonAuthRoutes, routes } from "./allRoutes"; import NonLayout from "@src/layout/nonLayout"; import Layout from "@src/layout/layout"; const Routing = () => { return ( <Routes> {/* Routes with Sidebar & Topbar */} {routes.map((item, key) => ( <Route key={key} path={item.path} element={<Layout>{item.component}</Layout>} /> ))} {/* Routes without Sidebar & Topbar */} {nonAuthRoutes.map((item, key) => ( <Route key={key} path={item.path} element={<NonLayout>{item.component}</NonLayout>} /> ))} </Routes> ); }; export default Routing;
App.jsx
// src/App.jsx import { BrowserRouter } from "react-router-dom"; import Routing from "./routes/Routing"; function App() { return ( <Routing /> ); } export default App;
Open your browser and go to:
routes
, it will have the sidebar.nonAuthRoutes
, it will not have the sidebar.Be the first to know about new updates and exclusive discounts. No spam, just great offers!
How about
With over 7 years of experienced team, we specialize in delivering custom projects for startups, blue-chip companies, and government agencies. We have successfully completed over 250+ projects, providing tailored solutions that meet the unique needs of each client.
Hire Us© Domiex Created & Crafted by SRBThemes.