Creating Routes and Links
Routes
define which components show based on the URL. Link
lets you navigate between routes without page reload.
import { Routes, Route, Link } from "react-router-dom";
function App() {
return (
<>
<nav>
<Link to="/">Home</Link> | <Link to="/about">About</Link>
</nav>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/about" element={<About />} />
</Routes>
</>
);
}