Routing is what turns a single component into a complete application. It manages the relationship between the browser's address bar and the content displayed on screen, providing the 'multi-page' feel without the performance cost of a reload.
1The Single Page Paradigm
In a traditional website, clicking a link sends a request to the server, which sends back a whole new HTML file. In a React SPA, the 'Router' intercepts the click. It prevents the default reload, updates the URL in the browser's history API, and swaps the visible component tree. This result is an app that feels instantaneous, as only the necessary parts of the UI are updated.
2Dynamic Routing Patterns
Modern apps are driven by dynamic content. Instead of creating a unique route for every user, we create a template route like /user/:username. The colon indicates a variable. React Router captures this variable and makes it available to your component via the useParams hook. This allows you to build a single Profile component that can display data for thousands of different users based on the URL.
