Giter Site home page Giter Site logo

mulxcode / angularfire Goto Github PK

View Code? Open in Web Editor NEW

This project forked from angular/angularfire

0.0 0.0 0.0 10.93 MB

The official Angular library for Firebase.

Home Page: https://firebaseopensource.com/projects/angular/angularfire2

License: MIT License

Shell 0.26% JavaScript 6.45% TypeScript 89.94% CSS 2.23% HTML 0.06% Nunjucks 1.07%

angularfire's Introduction

AngularFire

The official Angular library for Firebase.

ng add @angular/fire

Note: If you want to ng add AngularFire and will be using Hosting/Cloud Functions, you need to configure the Firebase CLI first so that you are logged in for the schematics that are run as part of ng add @angular/fire. Follow this guide to have the Firebase CLI walk you through the setup.

AngularFire smooths over the rough edges an Angular developer might encounter when implementing the framework-agnostic Firebase JS SDK & aims to provide a more natural developer experience by conforming to Angular conventions.

  • Dependency injection - Provide and Inject Firebase services in your components
  • Zone.js wrappers - Stable zones allow proper functionality of service workers, forms, SSR, and pre-rendering
  • Observable based - Utilize RxJS rather than callbacks for realtime streams
  • NgRx friendly API - Integrate with NgRx using AngularFire's action based APIs.
  • Lazy-loading - AngularFire dynamically imports much of Firebase, reducing time to load your app
  • Deploy schematics - Get your Angular application deployed on Firebase Hosting with a single command
  • Google Analytics - Zero-effort Angular Router awareness in Google Analytics
  • Router Guards - Guard your Angular routes with built-in Firebase Authentication checks

Example use

import { provideFirebaseApp, getApp, initializeApp } from '@angular/fire/app';
import { getFirestore, provideFirestore } from '@angular/fire/firestore';

@NgModule({
  imports: [
    provideFirebaseApp(() => initializeApp({ ... })),
    provideFirestore(() => getFirestore()),
  ],
  ...
})
export class AppModule { }
import { inject } from '@angular/core';
import { Firestore, collectionData, collection } from '@angular/fire/firestore';
import { Observable } from 'rxjs';

interface Item {
  name: string,
  ...
};

@Component({
  selector: 'app-root',
  template: `
  <ul>
    <li *ngFor="let item of item$ | async">
      {{ item.name }}
    </li>
  </ul>
  `
})
export class AppComponent {
  item$: Observable<Item[]>;
  firestore: Firestore = inject(Firestore);

  constructor() {
    const itemCollection = collection(this.firestore, 'items');
    this.item$ = collectionData(itemCollection);
  }
}

Compatibility

Angular and Firebase versions

AngularFire doesn't follow Angular's versioning as Firebase also has breaking changes throughout the year. Instead we try to maintain compatibility with both Firebase and Angular majors for as long as possible, only breaking when we need to support a new major of one or the other.

Angular Firebase AngularFire
16 9 ^7.6
15 9 ^7.5
14 9 ^7.4
13 9 ^7.2
12 9 ^7.0
12 7,8 ^6.1.5
11 7,8 ^6.1
10 8 ^6.0.4
10 7 ^6.0.3
9 8 ^6.0.4
9 7 ^6.0

Version combinations not documented here may work but are untested and you will see NPM peer warnings.

Polyfills

Neither AngularFire or Firebase ship with polyfills. To have compatibility across as wide-range of environments we suggest the following polyfills be added to your application:

API Environments Suggested Polyfill License
Various ES5+ features Safari < 10 core-js/stable MIT
globalThis Chrome < 71
Safari < 12.1
iOS < 12.2
Node < 12
globalThis MIT
Proxy Safari < 10 proxy-polyfill Apache 2.0
fetch Safari < 10.1
iOS < 10.3
cross-fetch MIT

Resources

Quickstart - Get your first application up and running by following our quickstart guide.

Contributing

Stackblitz Template - Remember to set your Firebase configuration in app/app.module.ts.

Upgrading to v7.0? Check out our guide.

Sample apps

We have three sample apps in this repository:

  1. samples/compat a kitchen sink application that demonstrates use of the "compatibility" API
  2. samples/modular a kitchen sink application that demonstrates the new tree-shakable API
  3. samples/advanced the same app as samples/modular but demonstrates more advanced concepts such as Angular Universal state-transfer, dynamically importing Firebase feature modules, and Firestore data bundling.

Having troubles?

Get help on our Q&A board, the official Firebase Mailing List, the Firebase Community Slack (#angularfire2), the Angular Community Discord (#firebase), Gitter, the Firebase subreddit, or Stack Overflow.

NOTE: AngularFire is maintained by Googlers but is not a supported Firebase product. Questions on the mailing list and issues filed here are answered on a best-effort basis by maintainers and other community members. If you are able to reproduce a problem with Firebase outside of AngularFire's implementation, please file an issue on the Firebase JS SDK or reach out to the personalized Firebase support channel.

Developer Guide

This developer guide assimes you're using the new tree-shakable AngularFire API, if you're looking for the compatability API you can find the documentation here.

See the v7 upgrade guide for more information on this change..

Firebase product integrations

import { } from '@angular/fire/analytics';
import { } from '@angular/fire/auth';
import { } from '@angular/fire/firestore';
import { } from '@angular/fire/functions';
import { } from '@angular/fire/messaging';
import { } from '@angular/fire/storage';
import { } from '@angular/fire/performance';
import { } from '@angular/fire/database';
import { } from '@angular/fire/remote-config';
import { } from '@angular/fire/app-check';

Deploying your site

  • Deploy to Firebase Hosting
  • Angular Universal: Deploy to Cloud Functions
  • Angular Universal: Deploy to Cloud Run

angularfire's People

Contributors

bananer avatar bob-lee avatar cartant avatar codediodeio avatar danielsogl avatar davideast avatar dependabot[bot] avatar fabien0102 avatar goldblatt avatar hiepxanh avatar jamesdaniels avatar jeffbcross avatar jteplitz avatar jymdman avatar kingdarboja avatar maistho avatar markgoho avatar mikedory avatar mukesh51 avatar myspivey avatar nothingeverhappens avatar orahul1 avatar piusnyakoojo avatar redian avatar robwormald avatar ryanclark avatar sarunint avatar splaktar avatar valentinfunk avatar vicb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.