A simple React project demonstrating routing, dynamic routes, and reusable layout components using React Router.
- React – For building the user interface and managing state.
- Vite – For fast development and build tooling.
- Tailwind CSS – For utility-first, responsive styling.
- React Router – For client-side routing and navigation.
- Header and Footer: Reusable layout components rendered on every page.
- Nested Routing: Uses
<Outlet />to render child routes within the main layout. - Dynamic Routes: Supports dynamic user pages (e.g.,
/user/123) using React Router'suseParamshook. - Responsive Design: Styled with Tailwind CSS for a modern look.
- The
App.jsxfile sets up the main layout with a header, footer, and an<Outlet />for nested routes. - The
User.jsxcomponent usesuseParamsfrom React Router to read the dynamicuseridfrom the URL and display it. - The
FooterandHeadercomponents are always visible, regardless of the current route.
Visiting /user/42 will render:
User: 42
- Outlet: For nested routing and layouts.
- useParams: To access dynamic route parameters.
- Link: For navigation between routes (used in header/footer).
- Route: For defining static and dynamic routes.
-
Clone the repository:
git clone https://github.com/ujjwal1207/reactrouting.git cd routerpage -
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Open http://localhost:5173 in your browser.
This project is licensed under the MIT License.