Dynamic Routes and Params
You can create dynamic routes using :
followed by a parameter name.
<Route path="/user/:id" element={<User />} />
Use useParams
to access the dynamic part of the route:
import { useParams } from "react-router-dom";
function User() {
const { id } = useParams();
return <h1>User ID: {id}</h1>;
}