This project is a simple and responsive React website built with React Router. It demonstrates how to create a single-page application (SPA) with multiple sections and a shared layout for smooth navigation.
-
Routing with React Router
- Seamless navigation between pages without refreshing the browser.
- Pages include Home, Service, Accessories, and About.
-
Shared Layout
- A common layout (
RootLayout) that contains a navigation bar and a placeholder for page content.
- A common layout (
-
Responsive Navigation Bar
- Includes a mobile-friendly menu toggle using
useState. - Styled with Tailwind CSS for a clean and modern design.
- Includes a mobile-friendly menu toggle using
-
Reusable Components
- Navigation bar and individual pages are modular, making the project easy to maintain and expand.
-
Organized Folder Structure
- Components, pages, layouts, and assets (like images) are stored in separate folders for better organization.
project/
├── public/
├── src/
│ ├── Components/
│ │ └── Navbar.jsx
│ ├── Layout/
│ │ └── RootLayout.jsx
│ ├── Pages/
│ │ ├── Home.jsx
│ │ ├── Service.jsx
│ │ ├── Accessories.jsx
│ │ └── About.jsx
│ ├── data/
│ │ └── data.js
│ ├── App.jsx
│ ├── main.jsx
│ ├── index.css
│ └── vite.config.js
└── package.json
- React.js: For building the website.
- React Router: For handling navigation between pages.
- JavaScript (ES6): For logic and functionality.
- CSS (Tailwind): For responsive and modern styling.
- Lucide-React: For icons in the navigation bar.
- Vite: For project setup and development server.
first intall node modules
npm install / npm i
Start the development server:
npm run devOpen the app in your browser:
http://localhost:5173
-
Starting Point:
- The app starts from
main.jsx, where React Router is initialized.
- The app starts from
-
Routing:
- Routes are defined in
App.jsx, linking paths (e.g.,/service) to corresponding page components.
- Routes are defined in
-
Shared Layout:
RootLayout.jsxensures that the navigation bar and page content are consistent across all pages.
-
Navigation Bar:
Navbar.jsxrenders navigation links dynamically from an array.- Mobile-friendly menu toggle functionality is implemented using
useState.
-
Pages:
- Each page (e.g., Home, Service) is defined in separate components under the
Pagesfolder.
- Each page (e.g., Home, Service) is defined in separate components under the