When building modern React applications, you often have complex layouts like dashboards, profiles, or admin panels — where multiple pages share common UI parts like a sidebar, header, or footer.
You also need security controls — for example, only logged-in users should access certain routes.
React Router provides two powerful tools for this:
Nested Routes – for structured, hierarchical layouts.
Route Guards – for protecting private or restricted pages.