This project demonstrates a simple implementation of user authentication using Django on the backend and React on the frontend. It utilizes the SimpleJWT library for token-based authentication.
- User registration and login
- Token-based authentication using SimpleJWT
- Protected routes for authenticated users
- Logout functionality
- Django
- Django Rest Framework
- SimpleJWT
- React
- React Router
- Axios
-
Clone the repository:
git clone https://github.com/moti9/Django-React-Authentication.git cd Django-React-Authentication
-
Set up a virtual environment and install dependencies:
cd backend python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt
-
Run migrations:
python manage.py migrate
-
Start the Django development server:
python manage.py runserver
-
In a new terminal window, navigate to the project root:
cd Django-React-Authentication
-
Install frontend dependencies:
cd frontend npm install
-
Start the React development server:
npm start
- Open your browser and go to http://localhost:8000 to access the React app.
- Register a new account or log in with existing credentials.
- Explore the protected routes available to authenticated users.
- Log out when done.
If you'd like to contribute to this project or want to make it more efficient, please follow these steps:
- Fork the repository.
- Create a new branch (git checkout -b feature/your-feature).
- Commit your changes (git commit -am 'Add new feature').
- Push to the branch (git push origin feature/your-feature).
- Create a new pull request.
This project is licensed under the MIT License - see the LICENSE.md
file for details.