Skip to content Skip to sidebar Skip to footer

Widget HTML #1

Weekend Project: Time Tracker Using ReactJS and Firebase

In this weekend project, we will be building a Time Tracker application using ReactJS and Firebase. The Time Tracker will allow users to log their activities and track the time spent on each task. Firebase will be used as the backend to store the data and provide real-time synchronization. This project is a great opportunity to learn and apply ReactJS concepts along with integrating a powerful backend solution like Firebase.

Prerequisites: To follow along with this project, you should have a basic understanding of HTML, CSS, and JavaScript. Familiarity with ReactJS and Firebase will be helpful but not mandatory. Make sure you have Node.js and npm (Node Package Manager) installed on your machine.

Setting up the Project:

  1. Create a new ReactJS project using Create React App. Open your terminal and run the following command:
    npx create-react-app time-tracker
  2. Navigate to the project directory:
    cd time-tracker
  3. Install the Firebase SDK by running the following command:
    npm install firebase

Setting up Firebase:

  1. Go to the Firebase console ( and create a new project.
  2. Once the project is created, click on "Add app" and select the web platform.
  3. Register your app by providing a name for your web app.
  4. Firebase will generate a configuration object with your app's credentials. Copy this configuration object.

Connecting Firebase to the React App:

  1. In your React project, open the src directory and create a new file called firebase.js.
  2. Paste the copied configuration object into the firebase.js file.
  3. Import the necessary Firebase modules and initialize Firebase in the file. Your firebase.js file should look like this:
import firebase from 'firebase/app'; import 'firebase/firestore'; const firebaseConfig = { // Your Firebase configuration object }; firebase.initializeApp(firebaseConfig); export default firebase;

Building the Time Tracker:

  1. In the src directory, create a new directory called components.
  2. Inside the components directory, create a new file called TimeTracker.js.
  3. Open the TimeTracker.js file and import React and the Firebase module you installed earlier.
  4. Create a functional component called TimeTracker and export it as the default component.
  5. Within the TimeTracker component, initialize a Firestore reference to the collection you'll use to store the time entries. You can do this by adding the following code:
const db = firebase.firestore(); const timeEntriesRef = db.collection('timeEntries');
  1. Next, create a form within the TimeTracker component to allow users to log their activities. The form should include fields for the task name and the time spent.
  2. Add an onChange event handler to update the component's state whenever the form fields change.
  3. Add an onSubmit event handler to handle the form submission. Inside the event handler, use the timeEntriesRef to add a new document to the collection with the submitted data.
  4. Retrieve the time entries from Firebase and display them in a list below the form. You can use the Firestore onSnapshot method to listen for real-time updates to the collection and update the component's state accordingly.
  5. Style the Time Tracker application using CSS to make it visually appealing.


Congratulations! You have successfully built a Time Tracker application using ReactJS and Firebase. This project demonstrates the power of React's component-based architecture and Firebase's real-time synchronization capabilities. You can further enhance the application by adding features like authentication, editing/deleting time entries, and generating reports based on the logged data. Exploring ReactJS and Firebase together opens up a world of possibilities for building powerful web applications. Happy coding!

Learn more