A ready-to-use React.js template with complete authentication system including email/password and Google OAuth integration. Perfect for competitions and rapid prototyping.
- ✅ Complete authentication system (Email/Password + Google OAuth)
- ✅ Protected routes with React Router
- ✅ Firebase integration
- ✅ Responsive design
- ✅ Modern React hooks and context API
- ✅ Clean, organized project structure
- ✅ Ready for competition use
- Node.js (v14 or higher)
- npm or yarn
- Firebase account
-
Clone or download this template
git clone <repository-url> cd reactjs-template
-
Install dependencies
npm install
-
Set up Firebase
- Go to Firebase Console
- Create a new project or use existing one
- Enable Authentication and add Email/Password and Google as sign-in methods
- Get your Firebase configuration from Project Settings
-
Configure environment variables
cp .env.example .env
Edit
.envand add your Firebase configuration:REACT_APP_FIREBASE_API_KEY=your_api_key_here REACT_APP_FIREBASE_AUTH_DOMAIN=your_project_id.firebaseapp.com REACT_APP_FIREBASE_PROJECT_ID=your_project_id REACT_APP_FIREBASE_STORAGE_BUCKET=your_project_id.appspot.com REACT_APP_FIREBASE_MESSAGING_SENDER_ID=your_sender_id REACT_APP_FIREBASE_APP_ID=your_app_id
-
Start the development server
npm start
Open http://localhost:3000 to view it in the browser.
- Go to Firebase Console
- Click "Create a project"
- Follow the setup wizard
- In your Firebase project, go to "Authentication"
- Click "Get started"
- Go to "Sign-in method" tab
- Enable "Email/Password"
- Enable "Google" and configure OAuth consent screen
- Go to Project Settings (gear icon)
- Scroll down to "Your apps" section
- Click on "</>" (Web) to add a web app
- Register your app and copy the configuration
- Go to Google Cloud Console
- Select your project
- Go to "APIs & Services" > "Credentials"
- Configure OAuth consent screen
- Add authorized domains (localhost:3000 for development)
src/
├── components/ # Reusable components
│ ├── Login.js # Login form component
│ ├── Signup.js # Signup form component
│ ├── Navbar.js # Navigation bar
│ └── PrivateRoute.js # Protected route wrapper
├── pages/ # Page components
│ ├── Home.js # Landing page
│ └── Dashboard.js # Protected dashboard
├── hooks/ # Custom React hooks
│ └── useAuth.js # Authentication hook and context
├── utils/ # Utility functions
│ └── firebase.js # Firebase configuration
├── App.js # Main app component with routing
├── index.js # App entry point
└── index.css # Global styles
npm start- Runs the app in development modenpm test- Launches the test runnernpm run build- Builds the app for productionnpm run eject- Ejects from Create React App (one-way operation)
- User registration with email and password
- User login with email and password
- Password confirmation on signup
- Form validation and error handling
- One-click Google sign-in
- Automatic user profile creation
- Seamless integration with Firebase Auth
- Dashboard accessible only to authenticated users
- Automatic redirect to login for unauthenticated users
- Persistent login state across browser sessions
- Create a new component in
src/pages/ - Add the route in
src/App.js - Optionally wrap with
PrivateRoutefor authentication
- Global styles are in
src/index.css - Component-specific styles can be added inline or as CSS modules
- The template uses a clean, responsive design that's easy to customize
- Enable the provider in Firebase Console
- Import the provider in
src/utils/firebase.js - Add the sign-in method in
src/hooks/useAuth.js - Create UI components for the new provider
All environment variables must be prefixed with REACT_APP_ to be accessible in the React app.
Required variables:
REACT_APP_FIREBASE_API_KEYREACT_APP_FIREBASE_AUTH_DOMAINREACT_APP_FIREBASE_PROJECT_IDREACT_APP_FIREBASE_STORAGE_BUCKETREACT_APP_FIREBASE_MESSAGING_SENDER_IDREACT_APP_FIREBASE_APP_ID
- Never commit your
.envfile to version control - Keep your Firebase API keys secure
- Configure Firebase security rules for production
- Use HTTPS in production
This template is specifically designed for coding competitions and hackathons:
- Fast setup - Get authentication working in minutes
- Clean codebase - Easy to understand and extend
- Modern practices - Uses latest React patterns
- Responsive design - Works on all devices
- Scalable structure - Easy to add new features
-
Firebase configuration errors
- Double-check your
.envfile - Ensure all required variables are set
- Verify Firebase project settings
- Double-check your
-
Google OAuth not working
- Check OAuth consent screen configuration
- Verify authorized domains in Google Cloud Console
- Ensure Google sign-in is enabled in Firebase
-
Build errors
- Run
npm installto ensure all dependencies are installed - Check for any missing environment variables
- Ensure Node.js version is 14 or higher
- Run
If you encounter issues:
- Check the browser console for error messages
- Verify Firebase configuration
- Ensure all environment variables are properly set
- Check Firebase Authentication logs in the console
After setting up the template:
- Customize the design to match your project needs
- Add your specific features and pages
- Configure additional Firebase services (Firestore, Storage, etc.)
- Set up deployment (Netlify, Vercel, Firebase Hosting)
- Add proper error boundaries and loading states
- Implement proper form validation
- Add tests for your components
This template is free to use for any purpose. Feel free to modify and distribute as needed.
Happy coding! 🚀