Jayant Shrivastava

Angular + Firebase: Build Powerful Web Apps Easily 🚀

GitHub Repo Releases

Download Releases

Table of Contents

Overview

Angular_Fire combines the power of Angular with the flexibility of Firebase. This project allows developers to create dynamic, real-time applications with minimal effort. With Angular’s robust framework and Firebase’s backend services, you can focus on building features without worrying about server management.

Features

Technologies Used

Installation

To get started with Angular_Fire, follow these steps:

  1. Clone the Repository:
    git clone https://github.com/jayant-cell/Angular_Fire.git
    
  2. Navigate to the Project Directory:
    cd Angular_Fire
    
  3. Install Dependencies:
    npm install
    
  4. Set Up Firebase:
    • Create a Firebase project in the Firebase Console.
    • Add your web app and copy the Firebase configuration.
  5. Configure Firebase in Your Project:
    • Open src/environments/environment.ts and add your Firebase config:
      export const environment = {
      production: false,
      firebase: {
        apiKey: "YOUR_API_KEY",
        authDomain: "YOUR_AUTH_DOMAIN",
        projectId: "YOUR_PROJECT_ID",
        storageBucket: "YOUR_STORAGE_BUCKET",
        messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
        appId: "YOUR_APP_ID"
      }
      };
      
  6. Run the Application:
    ng serve
    
  7. Access the App: Open your browser and go to http://localhost:4200.

Usage

After setting up the project, you can start building your application. Here are some examples of how to use the features:

Real-time Data

To fetch real-time data from Firestore:

import { AngularFirestore } from '@angular/fire/firestore';

constructor(private firestore: AngularFirestore) {}

getItems() {
  return this.firestore.collection('items').valueChanges();
}

Offline Support

To enable offline data persistence:

import { AngularFirestore } from '@angular/fire/firestore';

constructor(private firestore: AngularFirestore) {
  this.firestore.firestore.enablePersistence()
    .catch((err) => {
      console.error('Persistence failed', err);
    });
}

Notifications

Set up push notifications using Firebase Cloud Messaging:

import { AngularFireMessaging } from '@angular/fire/messaging';

constructor(private afMessaging: AngularFireMessaging) {
  this.afMessaging.requestToken.subscribe(
    (token) => {
      console.log('Permission granted! Save to the server!', token);
    },
    (error) => {
      console.error('Unable to get permission to notify.', error);
    }
  );
}

State Management with NgRx

Set up NgRx to manage your application’s state effectively:

import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';

export class AppComponent {
  items$: Observable<Item[]>;

  constructor(private store: Store<{ items: Item[] }>) {
    this.items$ = store.select('items');
  }

  loadItems() {
    this.store.dispatch(loadItems());
  }
}

Contributing

We welcome contributions to Angular_Fire. To contribute:

  1. Fork the repository.
  2. Create a new branch:
    git checkout -b feature/my-feature
    
  3. Make your changes and commit them:
    git commit -m "Add my feature"
    
  4. Push to your branch:
    git push origin feature/my-feature
    
  5. Create a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Releases

For the latest releases, visit the Releases section. You can download the latest version and execute it to see the new features in action.