Routing Is Needed in SPA

/           → <Home />
/about      → <About />
/profile    → <Profile /> 
// All inside <div id="root"></div>

Routing Works Internally;

[User clicks <Link> / useNavigate called]
            ↓
   BrowserRouter listens
            ↓
   Check <Routes> → match <Route path>
            ↓
  Render matched component in <div id="root">
            ↓
React updates Virtual DOM → minimal real DOM changes

Install React Router

npm install react-router-dom

This gives you: