A modern, high-fidelity React application demonstrating the power of React Router 6.4+ Data APIs. This project moves away from traditional useEffect data fetching in favor of Loaders for a faster, flicker-free user experience.
Instead of the old <BrowserRouter>, this project uses the Data Router setup.
- Benefit: Allows us to fetch data before the component even mounts.
- File:
App.jsx
The "Brain" of the data flow.
- Mechanism: We defined
profilesLoaderandprofileLoaderfunctions. - Result: No more "Loading..." spinners. The data is injected directly into the component via the
useLoaderData()hook.
- Concept: The Dashboard acts as a shell.
- Outlet: The
<Outlet />component inDashboard.jsxacts as a dynamic placeholder for nested children likeProfilesOverviewandProfile.
Used in the Profile page to grab the specific :id from the URL to display the correct user details.
src/
├── components/
│ └── Navbar.jsx # Sticky glassmorphism nav
├── pages/
│ ├── Home.jsx # App Manual & Root explanation
│ ├── About.jsx # Static route example
│ ├── Contact.jsx # useNavigate implementation
│ ├── Dashboard.jsx # Nested route parent (Outlet)
│ ├── ProfilesOverview.jsx # Loader & List view
│ ├── Profile.jsx # Dynamic params & Loader view
│ └── NotFound.jsx # Custom 404 handler
└── App.jsx # Router & Route definitions
-
Install dependencies:
npm install
-
Run the dev server:
npm run dev
-
Routing logic: Check
App.jsxto see how therouterobject is constructed usingcreateRoutesFromElements.
Every page in this project includes a "Knowledge Overlay" (Notes). These sections explain exactly which React Router hook or concept is being used in that specific component, making it a perfect learning template.