This project is a demonstration of routing between different components and pages using React Router. It includes components for forms, navigation, and route protection, along with several pages like Home
, Dashboard
, Login
, and Signup
.
- LoginForm.js: Handles the login form.
- SignupForm.js: Manages the signup form.
- Navbar.js: Contains the navigation bar for navigating between different routes.
- PrivateRoute.js: A higher-order component that guards private routes, ensuring that only authenticated users can access them.
- Template.js: Acts as a layout component for wrapping other components or pages.
- Dashboard.js: The dashboard page, accessible only after logging in.
- Home.js: The homepage of the application.
- Login.js: The page that contains the
LoginForm
component for user authentication. - Signup.js: The page that contains the
SignupForm
component for new user registration.
- Node.js: Ensure you have Node.js installed. You can download it from here.
-
Clone the repository:
git clone <repository-url>
-
Navigate to the project directory:
cd react-router-project
-
Install dependencies:
npm install
-
Start the development server:
npm start
-
Open your browser and navigate to:
http://localhost:3000
The project uses react-router-dom
to manage the routing between different pages. Here's how the routing is configured:
- Home Route (
/
): Renders theHome
component. - Login Route (
/login
): Renders theLogin
component. - Signup Route (
/signup
): Renders theSignup
component. - Dashboard Route (
/dashboard
): Renders theDashboard
component and is protected byPrivateRoute
.