OVERVIEW • APR 2025
Welcome to the comprehensive guide for using our Authentication Template. This powerful tool simplifies the implementation of secure user authentication in your projects.
FEATURES • APR 2025
Our Authentication Template is designed to simplify the implementation of secure user authentication in your web and mobile applications. With support for social logins, JWT-based sessions, and email verification, this template saves you time while maintaining high security standards.
INSTALLATION • APR 2025
Extract the template to your preferred project directory and open it in your code editor.
Open Frontend & Backend in different terminals
cd Frontend
npm install --legacy-peer-deps
cd ../Backend
npm install
Create a .env file in the backend & frontend directory with the necessary environment variables (details in the next section).
cd Backend
npm run dev
Open your browser and visit http://localhost:3000 to interact with the login interface.
CONFIGURATION • APR 2025
Create a .env file in the backend directory with the following variables:
MONGODB_URI=mongodb://localhost:27017/your_database
FRONTEND_URL=http://localhost:3000
BACKEND_URL=http://localhost:5000
SESSION_SECRET=your_secret_key
JSONWEBTOKEN_SECRET=your_jwt_secret
EMAIL_HOST=smtp.example.com
EMAIL_PORT=587
EMAIL_FROM=your_email@example.com
EMAIL_PASS=your_email_password
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
SESSION_SECRET & JWT_TOKEN
Use a secure random string generator to create these secret keys. You can use the following command in your terminal:
"node -e "console.log(require('crypto').randomBytes(64).toString('hex'))""
Run this command twice to generate both SESSION_SECRET and JSONWEBTOKEN_SECRET.
Email Configuration
To set up email configuration for Gmail:
Google OAuth Credentials
To set up Google OAuth:
GitHub OAuth Credentials
To set up GitHub OAuth:
CUSTOMIZATION • APR 2025
Modify React components and styles in the frontend/app folder to customize the UI.
├── Frontend
├── app
│ └── |── Dashboard
│ ├── forgot-password
│ ├── login
│ ├── signup
│ ├── api.js
│ ├── layout.ts
│ ├── page.ts
├── components
│ ├── ui
│ ├── Button.tsx
│ ├── Card.tsx
│ ├── Home.tsx
│ ├── Header.tsx
│ ├── Footer.tsx
|── hooks
│ ├── useAuth.js
|── lib
│ ├── utils.ts
|── public
| |── icons
| |── images
| |── favicon.ico
|── styles
| |── globals.css
|── .env
|── .gitignore
|── package.json
|── README.md
|── tsconfig.json
Add new routes in the backend/routes folder or modify existing middleware and controllers for specific business logic.
├── Backend
|── config
| ├── database.js
├── controllers
| ├── auth.js
| ├── users.js
├── middleware
| ├── auth.js
|── models
| ├── User.js
|── routes
| ├── auth.js
| ├── users.js
|── utils
| ├── email.js
├── server.js
|── .env
|── .gitignore
|── package.json
|── package-lock.json
|── README.md
TROUBLESHOOTING • APR 2025
Missing Environment Variables
Ensure the .env file exists in the backend directory and contains all required values.
Solution: Double-check your .env file and make sure all variables are correctly set.
Port Already in Use
Another process might be using the default port for the frontend or backend server.
Solution: Change the port in the respective configuration files or terminate conflicting processes.
OAuth Login Issues
Problems with Google or GitHub authentication could be due to misconfigured credentials.
Solution: Verify your Google and GitHub client credentials and ensure the redirect URIs are correctly set in your OAuth provider's dashboard.
TECH STACK • APR 2025