This project is a simple user login application built using Vite, React, TypeScript, and integrated with Auth0 for secure user authentication.
- Features
- Prerequisites
- Installation
- Configuration
- Usage
- Folder Structure
- Dependencies
- Contributing
- License
- User Authentication: Allows users to securely sign up, log in, and log out using Auth0 authentication.
- Protected Routes: Implements protected routes that can only be accessed by authenticated users.
- Type Safety: Written in TypeScript, providing type safety throughout the application.
Before you begin, ensure you have the following installed:
- Node.js (at least v14.x.x)
- npm or Yarn
- Auth0 account for authentication setup
-
Clone the repository:
git clone <repository-url>
-
Install dependencies:
cd your-project-folder npm install # or yarn install
To use Auth0 for authentication, follow these steps:
-
Create an Auth0 Account: Sign up or log in to your Auth0 account: Auth0 Dashboard.
-
Create a New Application:
- Go to the Applications section and create a new application.
- Choose
Single Page Web Applicationsas the application type. - Set the allowed callback URLs and logout URLs for your application (e.g.,
http://localhost:3000/callback).
-
Get Auth0 Credentials:
- Collect the
DomainandClient IDfrom the created Auth0 application. - Update the configuration in the project to include these credentials.
- Collect the
-
Environment Variables: Store your Auth0 credentials as environment variables or in a configuration file (e.g.,
.envor.env.local). Never expose your credentials in the codebase.
After setting up the project and configuring Auth0:
-
Run the development server:
npm run dev # or yarn dev -
Access the application in your browser at
http://localhost:3000.
your-project-folder/
├── public/
│ └── index.html
├── src/
│ ├── components/
│ │ ├── AuthButton.tsx
│ │ └── ...
│ ├── pages/
│ │ ├── Home.tsx
│ │ ├── Profile.tsx
│ │ └── ...
│ ├── App.tsx
│ └── index.tsx
├── .gitignore
├── package.json
├── README.md
└── ...
- React: JavaScript library for building user interfaces
- Vite: Next-generation frontend tooling
- Auth0: Secure authentication and authorization platform
- TypeScript: Typed JavaScript at any scale