How to Create a Simple Task Manager App Using Firebase

Likhith SPLikhith SP
3 min read

Introduction

Task managers are useful apps that help us stay organized and productive. Building a task manager is also a fantastic beginner-friendly project that covers essential development skills. In this guide, you’ll learn how to create a simple yet effective task manager app using Firebase, a popular backend-as-a-service platform.

Section 1: What You’ll Learn and Build

  • Firebase Basics: Authentication, Firestore for database storage.

  • React for Front End: Building the interface and connecting it to Firebase.

  • Task Manager Features: Adding, viewing, and deleting tasks.

Section 2: Setting Up Firebase

  1. Create a Firebase Project
  • Go to Firebase Console and click “Add Project.”

  • Name your project, enable Google Analytics if desired, and finish setup.

    1. Set Up Firestore Database
  • In the Firebase Console, go to “Firestore Database” and click “Create Database.”

  • Set it to “Start in test mode” for simplicity during development.

    1. Enable Authentication
  • Go to “Authentication” in the Firebase Console and select “Get Started.”

  • Enable “Email/Password” under Sign-in methods to allow user accounts.

Section 3: Setting Up Your Development Environment

  • Install Node.js and npm if you haven’t already.

  • Set Up Your React Project

  • Run the following commands:

npx create-react-app task-manager
cd task-manager
npm install firebase

Section 4: Configure Firebase in Your React App

  1. Create a Firebase Config File
  • In your project’s src folder, create a new file called firebaseConfig.js.

  • Add your Firebase configuration, which you can find in the Firebase Console under “Project Settings”:

import { initializeApp } from "firebase/app";

import { getFirestore } from "firebase/firestore";

import { getAuth } from "firebase/auth";
const firebaseConfig = {

  apiKey: "YOUR_API_KEY",

  authDomain: "YOUR_PROJECT_ID.firebaseapp.com",

  projectId: "YOUR_PROJECT_ID",

  storageBucket: "YOUR_PROJECT_ID.appspot.com",

  messagingSenderId: "YOUR_MESSAGING_SENDER_ID",

  appId: "YOUR_APP_ID"

};
const app = initializeApp(firebaseConfig);

const db = getFirestore(app);

const auth = getAuth(app);
export { db, auth };

Section 5: Creating the Task Manager Components

  1. Create the Task Component
  • This component will render each task and display options to delete or complete it.

    1. AddTask Component
  • This component includes a form for users to add tasks, with Firebase handling data persistence.

    1. Main App Component
  • Import your firebaseConfig and set up authentication logic.

  • Use Firestore’s collection and document methods to add, fetch, and delete tasks.

Section 6: Implementing CRUD Operations with Firebase

  1. Add Tasks to Firestore
  • Use addDoc to add a task:
import { addDoc, collection } from "firebase/firestore";
async function addTask(task) {

  await addDoc(collection(db, "tasks"), task);

}
  1. Fetch Tasks from Firestore
  • Use Firestore’s onSnapshot to display real-time updates of tasks.

    1. Delete Tasks
  • Use the deleteDoc method to delete tasks from the database.

Section 7: Styling and Final Touches

  • Add custom CSS for layout and design.

  • Consider responsive styling to make the app look good on mobile and desktop.

Conclusion

You’ve now created a basic task manager with React and Firebase, covering Firebase setup, CRUD operations, and styling. With these foundational skills, you can enhance the app with more features, like user authentication or notifications. Firebase’s real-time capabilities and React’s versatility make this a powerful combo for your future projects!

0
Subscribe to my newsletter

Read articles from Likhith SP directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Likhith SP
Likhith SP

My mission is to help beginners in technology by creating easy-to-follow guides that break down complicated operations, installations, and emerging technologies into bite-sized steps.