React Router

Harry · 22 Sep 2026 · 1 views
Log in to track your progress and mark lessons complete.

Setup

npm install react-router-dom

Routes and Navigation

Map URLs to components with Routes and Route; navigate with Link, NavLink and useNavigate.

Params and Nesting

Read :id with useParams, ?q= with useSearchParams, and render child routes through Outlet.

Guards and Splitting

Wrap routes in a Protected component that redirects without a token; lazy-load heavy routes with Suspense; add a * 404 route last.

Key Points

  • Router maps URL to component with no reload.
  • NavLink tracks active state.
  • Split by route for smaller bundles.
Share this post:

Comments (0)

Please login or register to comment.

Create a free account to keep reading

You've enjoyed a free tutorial! Register (it's free) to unlock every tutorial, track your progress and save code.

or sign in with your account

Already have an account? Log in