This application uses react router for client-side routing. This document outlines how routes are organized and how to add new ones.
All route definitions are centralized in src/routes/index.tsx. The application uses the standard nested <Outlet /> pattern to inject the page content inside the shared layout MainLayout.
Our router is initialized using createBrowserRouter to enable APIs and history state management, allowing deep links and consistent 404 pages.
export const router = createBrowserRouter([
{
path: "/",
element: <App />,
errorElement: (
<MainLayout>
<NotFoundPage />
</MainLayout>
),
children: [
{
index: true,
element: <UploadPage />,
},
// Insert new pages here
],
},
]);- Create the Page Component: Add a new
.tsxfile insrc/pages/(e.g.,NewPage.tsx). - Export the Page Component:
export const NewPage: React.FC = () => { return <div>...</div> } - Register the Route: Open
src/routes/index.tsx, import your new page, and add a new object to thechildrenarray under the root path/.
{
path: 'new-route', // this corresponds to /new-route
element: <NewPage />,
}- Add Navigation (Optional): If this page needs to be accessible from the header nav, open
src/components/Header.tsxand add a<NavLink to="/new-route">New Route</NavLink>inside the.nav-linkscontainer.
Navigating to any path not explicitly defined in the children array will fallback to path: '*' or the main errorElement, which renders the NotFoundPage wrapped inside the MainLayout.
Note: This file is a duplicate of
reference/routing.md.